I am on part 4 django tutorial. The tutorial is very good and I easily get 
on part 4 but....

I get error: Reverse for 'detail' with arguments '('',)' and keyword 
arguments '{}' not found. 1 pattern(s) tried: 
[u'polls/(?P<question_id>\\d+)/$']

Am I missing something?

My code is following:

urlpatterns = patterns('',
>     url(r'^$', views.index, name='index'),
>     url(r'^(?P<question_id>\d+)/$', views.detail, name='detail'),
>     url(r'^(?P<question_id>\d+)/results/$',views.results, name='results'),
>     url(r'^(?P<question_id>\d+)/vote/$', views.vote, name='vote'),
>


views.py:

from django.shortcuts import get_object_or_404, render
> from django.http import HttpResponseRedirect, HttpResponse 
> from django.template import RequestContext, loader
> from polls.models import Question, Choice
> from django.http import Http404
> from django.core.urlresolvers import reverse
>
>
> def index(request):
>     latest_question_list =  Question.objects.order_by('-pub_date')[:5]
>     template = loader.get_template('polls/index.html') 
>     context = RequestContext(request, {'latest_question_list' : 
> latest_question_list, })
>     return HttpResponse(template.render(context))
>
> def detail(request, question_id):
>     try:
>         question = Question.objects.get(pk = question_id)
>     except Question.DoesNotExist:
>         raise Http404("Question ne postoji") 
>     return render(request, 'polls/detail.html', {'question': question})
>
> def results(request, question_id):
>     question = get_object_or_404(Question, pk = question_id) 
>     return render(request, 'polls/results.html', {'guestion': question})
>
>
> def vote(request, question_id):
>     p = get_object_or_404(Question, pk=question_id)
>     try:
>         selected_choice  = p.choice_set.get(pk=request.POST['choice'])
>     except (KeyError, Choice.DoesNotExist):
>         return render(request, 'polls/detail.html', {
>             'question': p,
>             'error_message': "Nijesi izabrao pitanje.",
>          })
>     else:
>         selected_choice.votes += 1
>         selected_choice.save()
>         return HttpResponseRedirect(reverse('polls:results', args=(p.id,)))
>





-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2e2320f1-6813-4e01-8b32-76694dbd22f8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to