Changing User ModelAdmin for Django admin
You have to unregister User
first:
class UserAdmin(admin.ModelAdmin):
list_display = ('email', 'first_name', 'last_name')
list_filter = ('is_staff', 'is_superuser')
admin.site.unregister(User)
admin.site.register(User, UserAdmin)
Maybe this question is also interesting for you: Customizing an Admin form in Django while also using autodiscover
As pointed by @haifeng-zhang in the comments, it is useful to extend the default UserAdmin instead.
The official documentation about this can be found here: https://docs.djangoproject.com/en/dev/topics/auth/customizing/#extending-the-existing-user-model
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
from django.contrib.auth.models import User
# Define a new User admin
class UserAdmin(BaseUserAdmin):
list_display = ('email', 'first_name', 'last_name')
list_filter = ('is_staff', 'is_superuser')
# Re-register UserAdmin
admin.site.unregister(User)
admin.site.register(User, UserAdmin)
Update tested with Django 3+
So you don't lose data like password encryption and the form itself, perform the import below
from django.contrib.auth.admin import UserAdmin
Define an AdminCustom class as the example and customize with the options you want, overriding the default.
class UserAdminCustom(UserAdmin):
list_display = ('email', 'first_name', 'last_name', 'is_staff', 'is_superuser')
list_filter = ('is_staff', 'is_superuser')
search_fields = ('username', )
And in the end, follow the example mentioned
admin.site.unregister(User)
admin.site.register(User, UserAdminCustom)