Reputation: 383
I have few models in my Django app. How do I imitate another app to create app section for one of my models in admin interface?
Upvotes: 2
Views: 987
Reputation: 2921
The AdminSite is responsible for creating the index page. The process is as such:
_build_app_dict
builds a dictionary containing various data (including model._meta.app_label) of all models registered with the given siteget_app_list
turns that dictionary into a list sorted by app label and by model (verbose) nameindex
method/view adds that app_list to the template contextIf all you want to do, is alter the appearance of the index page (say by adding a 'fake' app to group your models differently), creating a custom AdminSite and hooking into any of the four steps above might be a cleaner way than messing with the internal app registry.
Upvotes: 2
Reputation: 1984
You can try changing the app_label
of your models you want to move:
class Meta:
app_label = 'new_section'
Just make sure to adapt the FK and M2M fields accordingly.
See this answer.
Upvotes: 1