forked from tfbabi/cmdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadmin.py
37 lines (32 loc) · 1.41 KB
/
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
35
36
37
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from django.utils.translation import ugettext_lazy as _
from .models import CustomUser
from .forms import CustomUserChangeForm, CustomUserCreationForm
class CustomUserAdmin(UserAdmin):
# The forms to add and change user instances
# The fields to be used in displaying the User model.
# These override the definitions on the base UserAdmin
# that reference the removed 'username' field
fieldsets = (
(None, {'fields': ('username', 'email', 'password')}),
(_('Personal info'), {'fields': ('first_name', 'last_name',
'mobile', 'user_key', 'department')}),
(_('Permissions'), {'fields': ('is_active', 'is_staff', 'is_superuser',
'groups', 'user_permissions')}),
(_('Important dates'), {'fields': ('last_login', 'date_joined')}),
)
add_fieldsets = (
(None, {
'classes': ('wide',),
'fields': ('username', 'email', 'password1', 'password2')}
),
)
form = CustomUserChangeForm
add_form = CustomUserCreationForm
list_display = ('email', 'first_name', 'last_name',
'mobile',
'is_staff')
search_fields = ('email', 'first_name', 'last_name', 'mobile')
ordering = ('email',)
admin.site.register(CustomUser, CustomUserAdmin)