mirror of
https://github.com/MarcZierle/photo-log-backend.git
synced 2025-09-13 02:04:18 +00:00
Update admin.py
This commit is contained in:
parent
1ab3ae9066
commit
c084c609d3
@ -1,7 +1,37 @@
|
||||
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
|
||||
|
||||
# Register your models here.
|
||||
|
||||
admin.site.register(CustomUser, UserAdmin)
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user