Reputation: 139
I have this error since 2 days
TypeError at /manager/produit/detail/s/
produit_detail() got an unexpected keyword argument 'letter'
and I don't see the bug, can you help me?
This is my urls.py
:
url(r'^manager/produit/detail/(?P<letter>\w{1})/$',
'appli.views.produit_detail', name="produit_detail"),
this is views.py
def produit_detail(request,letter):
from appli.models import Produit produits = Produit.objetcs.filter(nom__startswith=letter) return render(request,'produit_detail.html')
i called the url from this template
<p>{% for i in l %}
<a href="{% url 'produit_detail' i %}">{{ i }}</a>
{% endfor %}</p>
Upvotes: 0
Views: 3066
Reputation: 22808
You can only put i if you put int value. If you want to call a string you must put the variable with the value like this.
<p>{% for i in l %}
Sample 1: <a href="{% url produit_detail letter=i %}">{{ i }}</a>
Sample 2: <a href="{% url appli:produit_detail letter=i %}">{{ i }}</a>
Sample 3: <a href="/manager/produit/detail/{{i}}">{{ i }}</a>
{% endfor %}
</p>You did not put value for letter
Upvotes: 1