kers/users/admin.py

29 lines
866 B
Python
Raw Normal View History

2020-07-22 00:52:02 +02:00
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from .forms import CustomUserCreationForm, CustomUserChangeForm
from .models import CustomUser
class CustomUserAdmin(UserAdmin):
add_form = CustomUserCreationForm
form = CustomUserChangeForm
model = CustomUser
list_display = ('username', 'is_staff', 'is_superuser')
list_filter = ('username', 'is_staff')
fieldsets = (
2020-07-22 05:03:01 +02:00
(None, {'fields': ('username', 'password', 'student_number', 'real_name',)}),
2020-07-22 00:52:02 +02:00
('Permissions', {'fields': ('is_staff', 'is_superuser')}),
)
add_fieldsets = (
(None, {
'classes': ('wide',),
'fields': ('username', 'password1', 'password2', 'is_staff')}
),
)
search_fields = ('username',)
ordering = ('username',)
admin.site.register(CustomUser, CustomUserAdmin)