I am trying to change the Users view in Django Admin to show different fields (now it shows by default: username, email address, first name, last name, staff status) I have tried this in the admin.py file:
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.models import User
# Register your models here.
UserAdmin.list_display = ['email', 'first_name', 'last_name', 'is_active', 'last_login']
admin.site.unregister(User)
admin.site.register(User, UserAdmin)
However I cannot get my admin Users view to change. Is there anything else I need to do? I am using Django 2.0
Quite simply: define your own UserAdmin
:
from django.contrib import admin
from django.contrib.auth.models import User
class MyUserAdmin(admin.ModelAdmin):
list_display = ['email', 'first_name', 'last_name', 'is_active', 'last_login']
admin.site.unregister(User)
admin.site.register(User, MyUserAdmin)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With