I’m looking for a good tutorial for URL namespaces in Django. I find official documentation a little too sparse – it lacks good examples. I found similar question here on stack, but the answers didn’t help me to fully understand the subject either.
Share
Agreed, the docs for this are rather confusing. Here’s my reading of it (NB: all code is untested!):
In
apps.help.urls:In your main
urls.py:In your template:
should produce the url
/help/.should produce the url
/ineedhelp/.should likewise produce the url
/ineedhelp/.Similarly,
reverse('help:index')should produce/help/.reverse('otherhelp:index')should produce/ineedhelp/.reverse('help:index', current_app='otherhelp')should likewise produce/ineedhelp/.Like I said, this is based on my reading of the docs and my existing familiarity with how things tend to work in Django-land. I haven’t taken the time to test this.