views:

148

answers:

1

How do you override the admin model for Users? I thought this would work but it doesn't?

class UserAdmin(admin.ModelAdmin):
    list_display = ('email', 'first_name', 'last_name')
    list_filter = ('is_staff', 'is_superuser')

admin.site.register(User, UserAdmin)

I'm not looking to override the template, just change the displayed fields & ordering.

Solutions please?

+4  A: 

You have to unregister User first:

class UserAdmin(admin.ModelAdmin):
    list_display = ('email', 'first_name', 'last_name')
    list_filter = ('is_staff', 'is_superuser')


admin.site.unregister(User)
admin.site.register(User, UserAdmin)

Maybe this question is also interesting for you: Customizing an Admin form in Django while also using autodiscover

Felix Kling
Ah perfect, thanks!
Leon
where would you normally place the above code?
second
@second: In a file called `admin.py` in the particular application., see also http://docs.djangoproject.com/en/1.2/ref/contrib/admin
Felix Kling