mirror of
https://github.com/MarcZierle/photo-log-backend.git
synced 2025-09-13 10:14:17 +00:00
38 lines
1.2 KiB
Python
Executable File
38 lines
1.2 KiB
Python
Executable File
from django.contrib import admin
|
|
from django.contrib.auth.admin import UserAdmin
|
|
from django.utils.translation import gettext_lazy as _
|
|
from accounts.models import CustomUser
|
|
|
|
|
|
class CustomUserAdmin(UserAdmin):
|
|
# Remove username from the fieldsets
|
|
fieldsets = (
|
|
(None, {'fields': ('email', 'password')}),
|
|
(_('Personal info'), {'fields': ('first_name', 'last_name')}),
|
|
(_('Permissions'), {
|
|
'fields': ('is_active', 'is_staff', 'is_superuser', 'groups', 'user_permissions'),
|
|
}),
|
|
(_('Important dates'), {'fields': ('last_login', 'date_joined')}),
|
|
)
|
|
|
|
# Remove username from the add_fieldsets
|
|
add_fieldsets = (
|
|
(None, {
|
|
'classes': ('wide',),
|
|
'fields': ('email', 'password1', 'password2'),
|
|
}),
|
|
)
|
|
|
|
# Update list_display to use email instead of username
|
|
list_display = ('email', 'first_name', 'last_name', 'is_staff')
|
|
|
|
# Update search_fields to use email instead of username
|
|
search_fields = ('email', 'first_name', 'last_name')
|
|
|
|
# Update ordering to use email instead of username
|
|
ordering = ('email',)
|
|
|
|
|
|
# Register your models here.
|
|
admin.site.register(CustomUser, CustomUserAdmin)
|