4

In the Django admin screen for displaying lists of users (with the header, Select user to change), there are the fields username/email, etc and staff_status. I would like to add the user's active status to that display.

Although most of the django-admin customization questions seem to involve extending the admin model - since this field already exists, I would think it only requires changing a template. However, I have looked at all the templates under admin and edit-inline, and if it's one of those, I can't tell. :)

So how do I add active status to the user-list display? A template change, and if so, which one? Note - I'm currently using Django 1.2, not the latest development version.

John C
  • 6,285
  • 12
  • 45
  • 69

2 Answers2

4

It's in http://code.djangoproject.com/browser/django/trunk/django/contrib/auth/admin.py:

class UserAdmin,

Add it to list_display (see django doc):

list_display = ('username', 'email', 'first_name', 'last_name', 'is_staff',
                'is_active')
manji
  • 47,442
  • 5
  • 96
  • 103
  • http://code.djangoproject.com/browser/django/tags/releases/1.2/django/contrib/auth/admin.py --- it's there also in 1.2 (directly under the auth directory) – manji Apr 14 '11 at 18:03
  • Arg, you're right, sorry - clicked on the wrong directory (sigh). – John C Apr 14 '11 at 18:09
  • 2
    The problem with that is that one day you will make an update, and your changes will be gone. Better look at this [answer](http://stackoverflow.com/questions/2270537/how-to-customize-the-auth-user-admin-page-in-django-crud) –  Sep 02 '16 at 08:52
  • Please refer to the answer provided by @RafaelSentiesMartielli. That's the proper one! – KunYu Tsai Dec 13 '20 at 23:09
0

Try this (Worked for me)-

from django.contrib.auth.admin import UserAdmin

UserAdmin.list_display = (....,'is_active')
David Buck
  • 3,752
  • 35
  • 31
  • 35