Friday, July 25, 2014

Official tutorial part 4

Hi, 

i have a problem in part 4 of official django tutorial, somebody can help me?

Error:
Reverse for 'polls.detail' with arguments '(4,)' and keyword arguments '{}' not found. 0 pattern(s) tried: []
Index.html (template)
{% if latest_poll_list %}  	    <ul>  	    {% for poll in latest_poll_list %}  	         <li><a href="{% url 'polls.detail' poll.id %}">{{ poll.question }}</a></li>  	    {% endfor %}  	    </ul>  {% else %}  	    <p>No polls are available.</p>  {% endif %}
views.py (polls)
from django.shortcuts import render, get_object_or_404  from django.http import HttpResponse  from polls.models import Poll  # Create your views here.  def index(request):      latest_poll_list = Poll.objects.order_by('-pub_date')[:5]      context = {'latest_poll_list':latest_poll_list}      return render(request, 'polls/index.html',context)  def detail(request,poll_id):      poll = get_object_or_404(Poll,pk=poll_id)      return render(request, 'polls/detail.html',{'poll':poll})  def results(request,poll_id):      return HttpResponse("You're looking at results of poll %s." % poll_id)  def vote(request,poll_id):      return HttpResponse("You're voting on poll %s." % poll_id)  

urls.py (mysite)

from django.conf.urls import patterns, include, url

from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
    # Examples:
    # url(r'^$', 'app.views.home', name='home'),
    # url(r'^blog/', include('blog.urls')),
    url(r'^polls/', include('polls.urls', namespace="polls")),
    url(r'^admin/', include(admin.site.urls)),
)

Thanks for any help.



--
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+unsubscribe@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/8b3cd25c-ef81-4c1d-afba-8d70cd3fdb2e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment