Hello everyone,
my Django app uses the customer-user model. Now I have two menus in the Django admin, both called ‘AUTHENTICATION AND AUTHORIZATION’. Would it be possible to merge these two menus? Thanks, Felix
So to be clear - you have two apps involved here. One app contains your custom user model. The other is the system-provided auth
app where you’re using the Group
model.
Is this correct?
yes, this is correct.
The short and direct answer is that you don’t - at least not easily.
By design, the Django admin is an internal tool designed to reflect the physical structure of your database.
Having said that, you can kind-of fool the admin.
- Ensure that
django.contrib.auth
appears before your app in theINSTALLED_APPS
list. - Create a proxy model for Group in your app.
- Unregister the
auth.Group
model in youradmin.py
file.* - Register your proxy model in the admin
*Note: This is why django.contrib.auth
needs to be before your app in INSTALLED_APPS
. If it’s not, then the Group
model will not be registered at the time you’re trying to deregister it.
*Note 2: If you’re intending to override any auth
templates, this isn’t going to work, because that requires your app to be before the auth
app in INSTALLED_APPS
.
— Option 2 —
<conjecture>
You may be able to create a custom AdminSite object, overriding the each_context
and get_app_list
methods to tailor the listing display as you see fit. (I’ve never tried anything like this, so this really is just a guess on my part.)
</conjecture>
Thanks for the explanations. I’ll let that go in this case. This is too complicated for me for the benefit that arises.