Reputation: 572
I was trying to customize Django (version 1.8) admin page of Users (which is under Authentication and Authorization on admin page), but I cannot get it to work.
Currently, the default admin page of Users shows 5 defaults fields: username, email address, first name, last name, staff status. And, I am trying to make the admin Users page show following fields: username, email. date_joined, last_login
So, I created admin.py file and saved it in the directory where wsgi.py is with the following code:
class UserAdmin(admin.ModelAdmin):
list_display = ("username", "email", "date_joined", "last_login")
class Meta:
model = User
admin.site.unregister(User)
admin.site.register(User, UserAdmin)
But, the code above did not force admin User page display the fields that I want it to display("username", "email", "date_joined", "last_login").
Then, I replaced the code above with the following code in admin.py:
class MyUserAdmin(UserAdmin):
list_display = ("username", "email", "date_joined", "last_login")
admin.site.unregister(User)
admin.site.register(User, MyUserAdmin)
But, no luck. There was a similar question on stackoverflow and answers to it (How to customize the auth.User Admin page in Django CRUD?), and above two blocks of code are what I was trying to do after reading the answers. But, I still cannot get it to work.
Can anyone help me?
Upvotes: 0
Views: 960
Reputation: 572
I just found out what the problem was. The problem was that I did not include the app in INSTALLED_APPS in settings.
Upvotes: 1