picomon
picomon

Reputation: 1519

NoReversematch Error In Django

I want to get an object by id, so when the user click on the title it will redirect the user to the page containing the id objects and I want my url link to be like this:

         http://127.0.0.1:8000/cripme/12/53-places-to-go

I tried the codes below but I'm getting this error:

  NoReverseMatch at /view_list/
  Reverse for 'cripdetail' with arguments '(1L, u'53 places to go')' and keyword arguments '{}' not found.

Views for redirecting of users:

def cripdetail(request,fimcrip_id, fimcrip_title):
    post=Fimcrip.objects.get(id=fimcrip_id) 
    return render_to_response('postme.html',{'post':post, 'Fimcrip':Fimcrip},context_instance=RequestContext(request))

url:

url(r'^cripme/(?P<fimcrip_id>\d+)/(?P<fimcrip_title>[-\d\w]+)/$', 'meebapp.views.cripdetail', name='cripdetail'),

Template:

<a href= "{% url cripdetail Flup.id Flup.title %}" >{{Flup.title}}</a>

How can I fix this?

Upvotes: 0

Views: 62

Answers (1)

Daniel Roseman
Daniel Roseman

Reputation: 599450

You're passing the title, not the slug. The title contains spaces which aren't accepted by your URL pattern. You should pass flup.slug.

Upvotes: 1

Related Questions