Skip to content Skip to sidebar Skip to footer

Django No Reverse Match

ok I was getting help from a kind person on this problem and would like to see if anyone can help here is my code. urls.py urlpatterns = patterns('', url(r'^venues/(?P

Solution 1:

Your venue object in your template is none, so it doesn't have a pk. In your template you aren't passing any venues object either. Perhaps simplifying your code a bit will help:

Adjusting your view method a bit:

from django.shortcuts import render

defvenue(request,venue_id):
    the_venue = get_object_or_404(Venue,pk=venue_id)
    return render(request,'venues/venueprofile',{'venue',the_venue})

Your template:

{% load url from future %}
<ahref="{% url 'venue' venue_id=venue.pk %}">{{venue.name}}</a>

Solution 2:

The value of venue.pk is empty string, since it does not match your regular expression, it is showing no reverse match problem.

{% load url from future %}
{% for v in venues %}
    {% with ven=v.venue profile=v %}
<a href="{% url 'venue' venue_id=venue.pk %}">{{ven.name}}</a> # Problem is that venue.pk is empty string

Reverse for 'venue' with arguments '()' and keyword arguments '{'venue_id': ''}' check here value of venue_id is ''.

Solution 3:

Replace

{% url 'venue' venue_id=venue.pk %}

with

{% url 'venue' venue_id=ven.pk %}

Post a Comment for "Django No Reverse Match"