How to reverse match multiple Django admin sites (Custom admin site namespaces) -
when extend adminsite
create admin site how go being able reverse match each site? seems admin
namespace hardcoded reverse('admin:index')
, there way supply custom namespace?
you may confused namespace in django. if interested clarify confusion, may read discussion here.
if want try solve problem, there specific documentation multiple admin sites.
below example solutions copied official documentation
example solution:
# urls.py django.conf.urls import url .sites import basic_site, advanced_site urlpatterns = [ url(r'^basic-admin/', basic_site.urls), url(r'^advanced-admin/', advanced_site.urls), ]
and
# sites.py django.contrib.admin import adminsite class myadminsite(adminsite): site_header = 'monty python administration' basic_site = myadminsite(name='myadminbasic') advanced_site = myadminsite(name='myadminadvanced')
reversing
reverse('myadminbasic:index') # /basic-admin/ reverse('myadminadvanced:index') # /advanced-admin/
Comments
Post a Comment