0

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?

1
  • Put admin.py into one of your apps rather then the root directory of your project. Commented Jan 27, 2016 at 16:29

1 Answer 1

1

I just found out what the problem was. The problem was that I did not include the app in INSTALLED_APPS in settings.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.