Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#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 Changed 3 years ago by anonymous

  • Component changed from Uncategorized to Testing framework
  • Keywords Tutorial added
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 3 years ago by aaugustin

  • Component changed from Testing framework to Documentation
  • Resolution set to needsinfo
  • Status changed from new to closed
  • Type changed from Uncategorized to Bug

Could you provide the full traceback? Thanks!

comment:3 Changed 3 years ago by anonymous

http://dpaste.com/777044/ , this is the traceback

comment:4 Changed 3 years ago by aaugustin

  • Resolution needsinfo deleted
  • Status changed from closed to reopened

comment:5 follow-up: Changed 3 years ago by timo

I can't reproduce this. Maybe if you pasted your polls/urls.py file that would help.

comment:6 in reply to: ↑ 5 Changed 3 years ago by anonymous

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 Changed 3 years ago by anonymous

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 Changed 3 years ago by anonymous

Another problem i once is

127.0.0.1:8000/admin/

returns AttributeError at /admin/

http://dpaste.com/hold/777831/

comment:9 Changed 3 years ago by anonymous

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 Changed 3 years ago by anonymous

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 Changed 3 years ago by timo

Those urls.py files work for me. Any chance you have an older version of Django on your python path?

comment:12 follow-up: Changed 3 years ago by timo

  • Resolution set to worksforme
  • Status changed from reopened to closed

comment:13 in reply to: ↑ 12 Changed 3 years ago by anonymous

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

Note: See TracTickets for help on using tickets.
Back to Top