Reputation: 79
I don't know why this error occurred no revers match
while I'm practicing Django.
I modified the shops.html code to link pizza but after this modifying, this error occurred
Reverse for 'pizza' with arguments '('',)' not found. 1 pattern(s) tried: ['shops/(?P<pizza_id>[0-9]+)$']
first code :
<ul>
{%for shop in shops%}
<li>
{{shop}}
</li>
second code:
<ul>
{%for shop in shops%}
<li>
<a href="{% url 'pizzas:pizza' pizza.id %}">{{shop}}</a></li>
I have Posted all codes in Pastebin if needed.
Upvotes: 0
Views: 42
Reputation: 2573
your problem is that instead of shop.pk
you used pizza.id
and that is not actually defined.
change this
{%for shop in shops%}
<li>
<a href="{% url 'pizzas:pizza' pizza.id %}">{{shop}}</a></li>
{%empty%}
<li>currently there is no pizza available</li>
{%endfor%}
to
{%for shop in shops%}
<li>
<a href="{% url 'pizzas:pizza' shop.pk %}">{{shop}}</a></li>
{%empty%}
<li>currently there is no pizza available</li>
{%endfor%}
Upvotes: 1