Django tries the wrong url pattern but I can not find my mistake.
urls.py
url(r'^message/(?P<advertisementid>(\d+))/$', chat_view, name="chat_view_with_toid"),
url(r'^profile/(?P<userid>(\d+))/$', profile_view, name="profile"),
url(r'^details/(?P<advertisementid>(\d+))/$', details_view, name='details'),
views.py
def details_view(request, advertisementid):
advertisement_data = Advertisement.objects.get(id=advertisementid)
return render(request, "details.html", {"advertisement_data": advertisement_data})
def profile_view(request, userid):
advertisements = Advertisement.objects.filter(user__id=userid)
return render(request, "profile.html", { 'advertisements': advertisements } )
details.html (from where I want to resolve to the users profile)
<a href="{% url 'profile' userid=advertisement_data.user.id %}" style="text-decoration:none;">
<input type="submit" class="details-btn-profile" value="Profile"></a>
<a href="{% url 'chat_view_with_toid' advertisementid=advertisement_data.id %}"
style="text-decoration:none">
<input type="submit" class="details-btn-contact" value="Kontakt"></a>
main.html
<a href="{% url 'details' advertisementid=advertisement.id %}">
<img src="{% static advertisement.image.url %}" alt="Image"/></a>
When I click on button class="details-btn-profile" Django gives me this error:
Reverse for 'details' with no arguments not found. 1 pattern(s) tried: ['details/(?P(\d+))/$']
Why does it resolve to details ? Any ideas ?