-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathadmin.py
More file actions
30 lines (20 loc) · 778 Bytes
/
admin.py
File metadata and controls
30 lines (20 loc) · 778 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from django.contrib import admin
from api.models.sale import Sale
from api.models.seller import Seller
from api.models.plan import Plan
class CustomModelAdminMixin(object):
"""
Thanks to: https://stackoverflow.com/a/28255245
"""
def __init__(self, model, admin_site):
self.list_display = [field.name for field in model._meta.fields if field.name != "id"]
super(CustomModelAdminMixin, self).__init__(model, admin_site)
class SaleAdmin(CustomModelAdminMixin, admin.ModelAdmin):
pass
class SellerAdmin(CustomModelAdminMixin, admin.ModelAdmin):
pass
class PlanAdmin(CustomModelAdminMixin, admin.ModelAdmin):
pass
admin.site.register(Sale, SaleAdmin)
admin.site.register(Seller, SellerAdmin)
admin.site.register(Plan, PlanAdmin)