<h1>{{ question.question_text }}</h1>
<ul>
{% for choice in question.choice_set.all %}
<li><a href="{% url 'detail' question.id %}">{{ choice.choice_text }}</a></li>
{% endfor %}
</ul>
urlpatterns = [
url(r'^$', 'index', name="index"),
url(r'^(?P<question_id>\d+)/$', views.detail, name="detail"),
url(r'^(?P<question_id>\d+)/results/$', 'results', name="results"),
url(r'^(?P<poll_id>\d+)/vote/$', 'vote', name="vote"),
]
Can you paste the entire error?
Also, read through the error page, it should show you which line is causing the problem.
-James
--
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...@googlegroups.com.
To post to this group, send email to django...@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/298b2f49-8374-4e54-bfd3-639a7de3af7f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reverse for 'detail' with arguments '(1,)' and keyword arguments '{}' not found. 0 pattern(s) tried: []
Request Method: | GET |
---|---|
Request URL: | http://localhost:8000/polls/1/ |
Django Version: | 1.8.4 |
Exception Type: | NoReverseMatch |
Exception Value: | Reverse for 'detail' with arguments '(1,)' and keyword arguments '{}' not found. 0 pattern(s) tried: [] |
Exception Location: | /usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py in _reverse_with_prefix, line 496 |
Python Executable: | /usr/bin/python |
Python Version: | 2.7.3 |
Python Path: | ['/var/www/django/mysite', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/PIL', '/usr/lib/python2.7/dist-packages/gst-0.10', '/usr/lib/python2.7/dist-packages/gtk-2.0', '/usr/lib/python2.7/dist-packages/ubuntu-sso-client', '/usr/lib/python2.7/dist-packages/ubuntuone-client', '/usr/lib/python2.7/dist-packages/ubuntuone-control-panel', '/usr/lib/python2.7/dist-packages/ubuntuone-couch', '/usr/lib/python2.7/dist-packages/ubuntuone-installer', '/usr/lib/python2.7/dist-packages/ubuntuone-storage-protocol'] |
Server time: | Sun, 4 Oct 2015 19:31:13 +0000 |
In template /var/www/django/mysite/polls/templates/polls/detail.html
, error at line 4
1 | <h1>{{ question.question_text }}</h1> |
---|---|
2 | <ul> |
3 |
{% for choice in question.choice_set.all %} |
4 |
---|
<li><a href=" {% url 'detail' question.id %} ">{{ choice.choice_text }}</a></li> |
5 | {% endfor %} |
---|---|
6 | </ul> |
7 |
My guess it's that your polls/urls.py file is not being processed/included properly since none of your URL patterns were even tried.
What does your mysite/urls.py file look like?
-James
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/370a3815-c5c7-4eb7-bd50-cfd689a44c96%40googlegroups.com.
from django.contrib import admin
urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
url(r'^polls/', include('polls.urls',namespace = "polls")),
].
> This is my mysite/url,py
>
> from django.contrib import admin
>
> urlpatterns = [
> url(r'^admin/', include(admin.site.urls)),
> url(r'^polls/', include('polls.urls',namespace = "polls")),
> ].
>
Oh, yep, there's the problem. You added a namespace called 'polls' but you aren't referencing it in your template, so the URL resolver isn't using your polls/urls.py file for that {% url %} call. You probably forgot to update the {% url %} tag after the tutorial portion that added the namespace to the mysite/urls.py file.
You need to update your {% url %} tag to use 'polls:detail' rather than just 'detail'.
See the last code box on that tutorial page: https://docs.djangoproject.com/en/1.8/intro/tutorial03/#namespacing-url-names
-James
--
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...@googlegroups.com.
To post to this group, send email to django...@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/CA%2Be%2BciUsnTc4ExDWWGycB5jt%3DBfNpnWxaYNi7tbVWggr%3DDC4qQ%40mail.gmail.com.