+1 for Jingo answer to your original question. With your clarifying comment for the answer in mind: This URL is not "application independent", it is the "admin" application URL.
Adding the URL to the admin site is similar to ModelAdmin by overriding get_urls (): https://docs.djangoproject.com/en/dev/ref/contrib/admin/#adding-views-to-admin-sites
EDIT:
https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.AdminSite
is an administrative site, by default, the βadmin site is created asβ django.contrib.admin.site β(and then, for example, your ModelAdmin is registered on this). So you can subclass AdminSite for your own MyAdminSite and override get_urls () there:
from django.contrib.admin import AdminSite class MyAdminSite(AdminSite): def get_urls(): ... ... my_admin_site = MyAdminSite() ... my_admin_site.register(MyModel, MyModelAdmin)
Make sure you now use my_admin_site in urls.py: https://docs.djangoproject.com/en/dev/ref/contrib/admin/#hooking-adminsite-instances-into-your-urlconf
Regarding the actual contents of get_urls (), see https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.get_urls (of course, calling super () MyAdminSite). Also pay attention to the convenient admin_view wrapper specified there.
PS: In theory, you can also simply define get_urls () and then monkeypatch the default admin site so that it uses your get_urls (), but I donβt know if this really works - you will probably have to disable it right after itβs first "import ...
source share