#18677 closed Bug (worksforme)
Tutorial Part 3 to Part 4 Instruction Failure
Reported by: | anonymous | Owned by: | nobody |
---|---|---|---|
Component: | Documentation | Version: | 1.4 |
Severity: | Normal | Keywords: | Tutorial |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
"Now, go to /polls/1/ in your browser and vote in the poll. You should see a results page that gets updated each time you vote. If you submit the form without having chosen a choice, you should see the error message."
from Tutorial Part 3
The intention is to vote in the poll and a result page should follow after you voted but that is not the case, I copy the code word for word. Ran the code and the debugger point back to this line in the polls/view.py
return HttpResponseRedirect(reverse('poll_results', args=(p.id,)))
typing " 127.0.0.1:8000/polls/1/vote " url equal AttributeError at /polls/1/vote
'str' object has no attribute 'regex'
Solution? Please
FYI try doing some debuggin on the tutorial before release it because it doesn't really help your cause if your tutorial buggy which currently doesn't help your cause in getting new developer to adopt django. tutorial
Change History (13)
comment:1 by , 12 years ago
Component: | Uncategorized → Testing framework |
---|---|
Keywords: | Tutorial added |
comment:2 by , 12 years ago
Component: | Testing framework → Documentation |
---|---|
Resolution: | → needsinfo |
Status: | new → closed |
Type: | Uncategorized → Bug |
comment:4 by , 12 years ago
Resolution: | needsinfo |
---|---|
Status: | closed → reopened |
follow-up: 6 comment:5 by , 12 years ago
I can't reproduce this. Maybe if you pasted your polls/urls.py file that would help.
comment:6 by , 12 years ago
Replying to timo:
I can't reproduce this. Maybe if you pasted your polls/urls.py file that would help.
from django.conf.urls import patterns, include, url
from django.views.generic import DetailView, ListView
from polls.models import Poll
# Uncomment the next two lines to enable the admin:
#from django.contrib import admin
#admin.autodiscover()
# put the common prefix and add them as the first argument to patterns(), polls.views
urlpatterns = patterns(,
# Examples:
# url(r'$', 'mysite.views.home', name='home'),
# url(r'mysite/', include('mysite.foo.urls')),
# Uncomment the admin/doc line below to enable admin documentation:
# url(r'admin/doc/', include('django.contrib.admindocs.urls')),
# Generic Views
url(r'$',
ListView.as_view(
queryset=Poll.objects.order_by('-pub_date')[:5],
context_object_name="latest_poll_list",
template_name='polls/index.html')),
url(r'(?P<pk>\d+)/$',
DetailView.as_view(
model=Poll,
template_name='polls/detail.html')),
url(r'(?P<pk>\d+)/results/$',
DetailView.as_view(
model=Poll,
template_name='polls/results.html'),
name='poll_results'),
url(r'(?P<poll_id>\d+)/vote/$','polls.views.vote'),
)
comment:7 by , 12 years ago
from django.conf.urls import patterns, include, url from django.views.generic import DetailView , ListView from polls.models import Poll # Uncomment the next two lines to enable the admin: #from django.contrib import admin #admin.autodiscover() # put the common prefix and add them as the first argument to patterns(), polls.views urlpatterns = patterns('', # Examples: # url(r'^$', 'mysite.views.home', name='home'), # url(r'^mysite/', include('mysite.foo.urls')), # Uncomment the admin/doc line below to enable admin documentation: # url(r'^admin/doc/', include('django.contrib.admindocs.urls')), # Generic Views url(r'^$', ListView.as_view( queryset=Poll.objects.order_by('-pub_date')[:5], context_object_name="latest_poll_list", template_name='polls/index.html')), url(r'^(?P<pk>\d+)/$', DetailView.as_view( model=Poll, template_name='polls/detail.html')), url(r'^(?P<pk>\d+)/results/$', DetailView.as_view( model=Poll, template_name='polls/results.html'), name='poll_results'), url(r'^(?P<poll_id>\d+)/vote/$','polls.views.vote'), )
comment:8 by , 12 years ago
Another problem i once is
127.0.0.1:8000/admin/
returns AttributeError at /admin/
comment:9 by , 12 years ago
Can't switch between http://127.0.0.1:8000/admin/ and http://127.0.0.1:8000/polls/ instead its either able to access to polls or admin by comment out the url(r'admin/', include('admin.site.urls') or url(r'polls/', include('polls.urls')
comment:10 by , 12 years ago
from django.conf.urls import patterns, include, url # Uncomment the next two lines to enable the admin: from django.contrib import admin admin.autodiscover() # put the common prefix and add them as the first argument to patterns() urlpatterns = patterns('', # Examples: # url(r'^$', 'mysite.views.home', name='home'), # url(r'^mysite/', include('mysite.foo.urls')), # Uncomment the admin/doc line below to enable admin documentation: # url(r'^admin/doc/', include('django.contrib.admindocs.urls')), url(r'^polls/', include('polls.urls')), url(r'^admin/', include(admin.site.urls)), )
comment:11 by , 12 years ago
Those urls.py files work for me. Any chance you have an older version of Django on your python path?
follow-up: 13 comment:12 by , 12 years ago
Resolution: | → worksforme |
---|---|
Status: | reopened → closed |
comment:13 by , 12 years ago
Replying to timo:
I think I figure out the problem, it because I'm run latest ubuntu version on a virtual machine (VMWare player) because when I ran it on my native windows machine I was able to transition properly.
Thanks for the help by the way.
Another question:
Is it possible to use CSS on django template because I'm have trouble getting my added CSS code along all the to display during my test run
{{{{% if latest_poll_list %}
<html>
<body>
<ul>
{% for poll in latest_poll_list %}
<li><a href="/polls/{{ poll.id }}/" class = "Button-Big" >{{ poll.question }}</a></li>
{% endfor %}
</ul>
{% else %}
<p>No polls are available.</p>
{% endif %}
</body>
</html>
}}}
Where class = "Button-Big" points to a css folder in the same directory
Could you provide the full traceback? Thanks!