I\'m trying to understand the django admin better and at the same time, I\'m trying to add one more field to the current user admin. In models.py I\'ve done
Use
Just figured this out, perhaps this could help you as well.
Since you don't mention that you have a separate profile, if you want to simply add a column to the existing User admin, you can do the following in admin.py
:
First you create a custom admin by subclassing UserAdmin
:
class CustomUserAdmin(UserAdmin):
list_display = UserAdmin.list_display + ('is_complete',)
def is_complete(self, obj):
# Example here, you can use any expression.
return SomeOtherClass.objects.get(my_field=obj).is_complete()
# Not required, but this gives you a nice boolean field:
is_complete.boolean = True
Then unregister the existing UserAdmin
and register your own:
admin.site.unregister(User)
admin.site.register(User, CustomUserAdmin)