1π
β
The username
field is still part of the search_fields
and the add_fieldsets
. You thus should remove the username
field there:
class CustomUserAdmin(UserAdmin):
list_display = ('email', 'is_staff', 'is_superuser')
readonly_fields = ('last_login', 'date_joined', 'uuid')
ordering = ('email',)
search_fields = ('first_name', 'last_name', 'email') # π no username
fieldsets = (
(
'Fields',
{
'fields': (
'email',
'uuid',
'date_joined',
'last_login',
'is_active',
'is_staff',
'is_superuser',
'groups',
'user_permissions',
'password',
)
},
),
)
add_fieldsets = (
(None, {
'classes': ('wide',),
'fields': ('email', 'password1', 'password2'),
# π without username
}),
)
admin.site.register(User, CustomUserAdmin)
Source:stackexchange.com