Fakultas Ilmu Komputer UI

admin.py 1.45 KB
Newer Older
Kefas Satrio Bangkit Solidedantyo's avatar
Kefas Satrio Bangkit Solidedantyo committed
1
from django.contrib import admin
Glenda Emanuella Sutanto's avatar
Glenda Emanuella Sutanto committed
2
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
Kefas Satrio Bangkit Solidedantyo's avatar
Kefas Satrio Bangkit Solidedantyo committed
3
4
from .models import CustomUser

Glenda Emanuella Sutanto's avatar
Glenda Emanuella Sutanto committed
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53

class UserAdmin(BaseUserAdmin):
    # The fields to be used in displaying the User model.
    # These override the definitions on the base UserAdmin
    # that reference specific fields on auth.User.
    list_display = ('email',)
    fieldsets = (
        (None, {'fields': (\
            'name',
            'email',
            'password',
            'groups',
            'diet_profile',
            'nutritionist',
            'date_joined',
            'is_staff',
            'is_active',
            'is_superuser',
            'user_permissions',
            'last_login'
        )}),
    )
    # add_fieldsets is not a standard ModelAdmin attribute. UserAdmin
    # overrides get_fieldsets to use this attribute when creating a user.
    add_fieldsets = (
        (None, {
            'classes': ('wide',),
            'fields': (\
                'name',
                'email',
                'password1',
                'password2',
                'groups',
                'diet_profile',
                'nutritionist',
                'date_joined',
                'is_staff',
                'is_active',
                'is_superuser',
                'user_permissions',
                'last_login'
            )}
        ),
    )
    search_fields = ('email',)
    ordering = ('email',)


admin.site.register(CustomUser, UserAdmin)