Anyone knows good Django URL namespaces tutorial? -
I'm looking for a good tutorial for URL namespace in Django. I find official documentation a little more sparse - it does not have good examples here I found it on the stack, but the answer does not help me understand this topic completely.
Agree, docs are rather confusing for this here's my reading (NB: all the code Is unchecked! ): apps.help.urls :
urlpatterns = [url (r '^ $') in , 'Apps.help.views.index', name = 'index'),]
.pi in your main urls :
'Urlpatterns = [url (' 'apps.help.urls'', namespace = 'help', ap_name = 'help')), url (r '^ ineedhelp /', Include ('apps.help.urls', namespace = 'otherholl', ap_name = 'help')),] template:
{% Url help: index%} url / Help / should be created.
{% url otherhelp: index%} url / ineedhelp / should be created. URL as
{% Current_app as 'other'%} {% url help: index%} {% endwith%} / ineedhelp / should be produced.
Similarly, reverse ('help: index') should / help / .
reverse ('otherhelp: free x') should / ineedhelp / .
Reverse ('support: index', current_app = 'otherhelp') should also be as I said, it is based on the reading of the docs and my current acquaintance how Django -Land works in things like / ineedhelp / .
I have not taken the time to do this test.
Comments
Post a Comment