I have 2 links in my html templates. The first link passes only 1 parameter for the URL parameters and the second channel 2. Like this:
<a href="/products/{{categ_name}}">{{categ_name}}</a> <a href="/products/{{categ_name}}/{{subcateg_name}}">{{subcateg_name}}</a>
Now when I click on the link with parameter 1, it works fine. I get the parameter value in django view.
But when I click on the link to two parameters, I get only the first parameter. I get None in the value of the second parameter.
My urls.py:
urlpatterns = patterns('', url(r'^products/(?P<categ_name>\w+)/', views.products, name='products_category'), url(r'^products/(?P<categ_name>\w+)/(?P<subcateg_name>\w+)/', views.products, name='products_subcategory'), url(r'^logout/',views.logoutView, name='logout'),)
My views.py:
def products(request, categ_name=None, subcateg_name=None): print categ_name, subcateg_name ...
How to get the value of the second parameter?
source share