开发者

Django admin - adding a field to displayed user list

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开发者_JAVA百科 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.


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')


Try this (Worked for me)-

from django.contrib.auth.admin import UserAdmin

UserAdmin.list_display = (....,'is_active')
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜