I
I
Ilya Ryabykin2018-12-27 21:15:03
Django
Ilya Ryabykin, 2018-12-27 21:15:03

How to add model to django.contrib.auth.admin?

Hello.
The second time I'm trying to issue a question, I deleted the previous one. realized that that option is not feasible.
The problem statement is as follows:
How to "add" a custom model to django.contrib.auth so that it is registered in admin.py and displayed in the admin interface in the "Users and groups" block?
5c25164f8879d095412645.png
To get it like this:
5c251af204881564285627.png
Before that, I tried to create another customauth app, in which AppConfig is inherited from django.contrib.auth, but it turned out to be some kind of game, I couldn’t finish it to the end and I think it won’t work, because jang has a highly encapsulated app-model-admin connection. If you want to see this idea - write in the comments, I'll post the structure.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vadim Shatalov, 2018-12-27
@netpastor

Try to create your own application, create proxy models for User and Group and add more of your own as needed.
In the admin panel, then register everything

A
Alexey Guest007, 2018-12-29
@Guest007

It's not clear what you want to add.
1) A model from another APP
2) A dynamically created model (for example, with a structure from a JSON file)
3) A native table from a database
4) something else?
The direction depends on it...
item 1 is not a question at all.
p.3 - native tables in the context of Django have already been discussed somewhere and more than once.
item 2 - there is still more work on dynamic creation of the model, and in the admin panel it will be displayed by itself ... The admin
panel works with standard models - this is its essence. If you have a model - everything is solved. If you don’t have a model, but an unknown nonsense with unpredictable API and behavior, it’s also solvable, but simply by adding a link in a separate admin section.
If the capabilities of the standard admin panel are not enough, write your own.
You just need to remember that Dzhang's Admin is not for the client, it's for you - (almost) direct access to the database.
So if you need a custom admin panel for a user/manager, look aside, for example https://github.com/adamcharnock/django-adminlte2 (everything can be done in one style, users will not even notice that they have their own world :- ) )
Or look towards completely custom admins (django-jet, django-admin2)
little information...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question