54👍
✅
None of the above. Just use admin.site.unregister(). Here’s how I recently added filtering Users on is_active in the admin (n.b. is_active filtering is now on the User model by default in Django core; still works here as an example), all DRY as can be:
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.models import User
class MyUserAdmin(UserAdmin):
list_filter = UserAdmin.list_filter + ('is_active',)
admin.site.unregister(User)
admin.site.register(User, MyUserAdmin)
2👍
I think it might be easier to do this with a custom auth backend and thus remove the need for a customized ModelAdmin.
I did something similar with this snippet:
http://www.djangosnippets.org/snippets/74/
- [Django]-Django: Reverse for 'detail' with arguments '('',)' and keyword arguments '{}' not found
- [Django]-Django, template context processors
- [Django]-Django: accessing the model instance from within ModelAdmin?
Source:stackexchange.com