views:

213

answers:

2

Hello,

I just want to add the subscription date in the User list in the Django CRUD Administration site. How can I do that ?

Thank you for your help

A: 

Assuming that your user class is User and your subscription date field is subscription_date, this is what you need to add on your admin.py

class UserAdmin(admin.ModelAdmin):
    list_display = ('subscription_date',)

admin.site.register(User, UserAdmin)
jpartogi
This can works even with the buildin auth.User?
Natim
This should inherit from the built-in UserAdmin, otherwise you lose all the rest of the customizations. And you have to unregister the built-in registration too; Natim's answer has the right code.
Carl Meyer
+3  A: 

I finally did like this in my admin.py file :

from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.models import User

UserAdmin.list_display = ('email', 'first_name', 'last_name', 'is_active', 'date_joined', 'is_staff')

admin.site.unregister(User)
admin.site.register(User, UserAdmin)
Natim
We can also extends the UserAdmin instead of dynamically modifying it !
Natim