In my last question, I asked how to get urls to work with a parameter before urls.py is included, and that worked. Django {% url%} when URLs with parameters like url (r '^ foo / <parameter> / $' include (some.urls))
Now I want to use the same included urls.py with namespaces .
urls.py
urlpatterns = patterns('', url(r'^/foo/(?P<parameter_1>\d+)/', include('bar.urls', namespace='foo', app_name='foo')), )
bar.urls.py
urlpatterns = patterns('', url(r'^/bar/$', 'bar.views.index', name='bar'), url(r'^/bar/(?P<parameter_2>\d+)/$', 'bar.views.detail', name='bar_detail'), )
To get the url in the template, I use:
1. {% url foo:bar parameter_1=1 %} or {% url for:bar 1 %} 2. {% url foo:bar_detail parameter_1=1 parameter_2=1 %} or {% url foo:bar_detail 1 1 %}
I expect to get the URL: 1. /foo/1/bar/ and 2. /foo/1/bar/1 , but it does not work.
Interesting: if I call:
1. {% url foo:bar %} 2. {% url foo:bar_detail parameter_2=1 %} or {% url foo:bar_detail 1 %}
I get the URL: 1. /foo/(?P<parameter_1>%5Cd+)/bar/ and 2. /foo/(?P<parameter_1>%5d+)/bar/1
My question is: did I have an error in my code or is the code not useful, what do I want to do.