-
Notifications
You must be signed in to change notification settings - Fork 1
/
admin.py
34 lines (22 loc) · 810 Bytes
/
admin.py
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
31
32
33
34
from django.contrib import admin
from django import forms
from sehha.models import Organization, Unit, Page
class UnitInline(admin.StackedInline):
fields = ('name', 'phone', 'fax', 'email')
model = Unit
class CustomOrgForm(forms.ModelForm):
# create_by = forms.CharField(disabled=True,)
class Meta:
model = Organization
fields = "__all__"
class OrgModelAdmin(admin.ModelAdmin):
form = CustomOrgForm
list_filter = ['tags']
inlines = [UnitInline]
def get_form(self, request, obj=None, **kwargs):
form = super(OrgModelAdmin, self).get_form(request, obj, **kwargs)
# form.base_fields['create_by'].initial=request.user
return form
admin.site.register(Organization, OrgModelAdmin)
admin.site.register(Unit)
admin.site.register(Page)