Nested includes and captured parameters
The docs state that "An included URLconf receives any captured parameters from parent URLconfs". And that does work as expected, when the child URLconf makes immediate use of the parameter -- that is, the child URLconf is a terminal node and doesn't include any further child URLconfs.
In my particular use-case, I find myself needing to use two levels of URLconf includes, and when I do this, the captured parameter seems to get lost along the way.
Examples:
a) In this scenario, "my_view" gets app1_pk passed in kwargs (expected behavior).
root urls.py:
…
url(r'^app1/(?P<app1_pk>\d+)/app2/', include('app2.urls')),
…
app2.urls.py:
…
url(r'^my_view/$', 'app2.views.my_view'),
…
b) In this scenario (my use-case), "my_view" does not get app1_pk passed in kwargs (but I do not expect this to be the correct behavior).
root urls.py:
…
url(r'^app1/', include('app1.urls')),
…
app1.urls.py:
…
url(r'^(?P<app1_pk>\d+)/app2/', include('app2.urls')),
…
app2.urls.py:
…
url(r'^my_view/$', 'app2.views.my_view'),
…
Is this expected behavior? Any thoughts?
Thanks in advance,
Jason
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/ebe111a9-b0f5-4a7b-9687-dc95ba1b016a%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home