I want to make an include in my urls.py referring to another urls in the same urls.py file.
My structure is as follows:
├── docs
├── requirements
├── scripts
└── sonata
├── person
│ ├── migrations
│ ├── templatetags
│ └── urls.py
├── registration
│ ├── migrations
│ └── urls.py
└── sonata
├── settings
└── urls.py
And I want every coming url with prefix 'pdf/' to add a value to kwargs and calling again the rest of url. This is my attempt:
urlpatterns = patterns('',
url(r'^$',TemplateView.as_view(template_name='registration/login.html')),
# This is my attempt for capturing the pdf prefix
# and calling this same file afterwards with the pdfOutput variable set to True
url(r'^pdf/', include('sonata.urls'), kwargs={'pdfOutput':True}),
url(r'^admin/', include(admin.site.urls)),
url(r'^person/', include('person.urls')),
url(r'^registration/', include('registration.urls')),
url(r'^menu/', registration_views.menu, name='menu'),
url(r'^customers/', person_views.customers, name='customers'),
url(r'^employees/', person_views.employees, name='employees'),
url(r'^alumns/', person_views.alumns, name='alumns'),
url(r'^teaching/', person_views.docencia, name='teaching'),
url(r'^i18n/', include('django.conf.urls.i18n')),
)
Is there any way of doing this? I looked at the docs. It seems pretty clear how to pass values, but after proving I can't make the include. (I don't want either to do include() with the [array] of patterns repeating all urls. This would break DRY principle).
Thanks in advance