Filipe Ferminiano
Filipe Ferminiano

Reputation: 8791

Template doesn't recognize url name

I have these two url confs which refers 2 totally diferent views:

 #category
    url(r'^(?P<cat>[^/]+)/$', 'reviews.views.category', name='category'),

    #produt
    url(r'^(?P<slug>[^/]+)/$', 'reviews.views.single_product', name='product_detail'),

And these links in my templates:

{% url 'category' cat='eletronics' %}
{% url 'product_detail' slug=values.3.0 %}

But, both links are going to 'category' view, instead of the second going to 'product_detail' view.

I know this because when I click on the second link, django returns a message with an error in a variable name which only exists in the 'category' view. But, if a change the order in urlconfs, so 'product_detail' view appears before 'category' view, then both links goes to 'product_detail' view.

How to solve this?

Upvotes: 0

Views: 97

Answers (1)

Geo Jacob
Geo Jacob

Reputation: 6009

You just change the category url like this

category

url(r'^category/(?P<cat>[^/]+)/$', 'reviews.views.category', name='category'),
#produt
url(r'^(?P<slug>[^/]+)/$', 'reviews.views.single_product', name='product_detail'),

Upvotes: 1

Related Questions