Any ideas why this returns a NoReverseMatch error? From a fork of djano-ratings called updown.
urls.py:
url(r'^(?P<object_id>\d+)/rate/(?P<score>[\d\-]+)/$', AddRatingFromModel(), {
'app_label': 'appname',
'model': 'Thing',
'field_name': 'rating',
}, name='thing_rating'),
The template:
<div id='vote'><a href='{% url thing_rating %}'>Up</a></div>
Thanks for any ideas!
EDIT: added view for clarity
def index(request):
thing_list = Thing.objects.all()
return render_to_response('index.html',
{'thing_list':thing_list},
context_instance=RequestContext(request))
You need to pass in arguments (I use keyword args here, but positional is okay too) for the url’s parameters.
In a list view, you’re probably iterating over your items, so something like this works:
I think you also need quotes around the url name.
Here’s more on the url tag: https://docs.djangoproject.com/en/dev/ref/templates/builtins/?from=olddocs#url