[Django] #22700: Wrong signature of def vote() in generic views

1 view
Skip to first unread message

Django

unread,
May 25, 2014, 10:57:49 AM5/25/14
to django-...@googlegroups.com
#22700: Wrong signature of def vote() in generic views
-------------------------------+--------------------
Reporter: cmeter@… | Owner: nobody
Type: Bug | Status: new
Component: Documentation | Version: 1.6
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
In the tutorial on Django v1.6 Part 4 you wrote in "Amend Views"
(https://docs.djangoproject.com/en/1.6/intro/tutorial04/#amend-views) in
the last block of code this line:
{{{
#!div style="font-size: 80%"
{{{#!python
def vote(request, poll_id):
....
}}}
}}}

But after changing to generic views, the method should look like this:

{{{
#!div style="font-size: 80%"
{{{#!python
def vote(request, pk):
p = get_object_or_404(Poll)
...
}}}
}}}

Otherwise the poll application won't work and throws this error:

TypeError at /polls/1/vote/
vote() got an unexpected keyword argument 'pk'
Request Method: POST
Request URL: http://127.0.0.1:8000/polls/1/vote/
Django Version: 1.6.5
Exception Type: TypeError
Exception Value:
vote() got an unexpected keyword argument 'pk'
Python Version: 3.4.1

--
Ticket URL: <https://code.djangoproject.com/ticket/22700>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 25, 2014, 2:13:44 PM5/25/14
to django-...@googlegroups.com
#22700: Wrong signature of def vote() in generic views
-------------------------------+--------------------------------------
Reporter: cmeter@… | Owner: nobody
Type: Bug | Status: closed
Component: Documentation | Version: 1.6
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by timo):

* status: new => closed
* needs_better_patch: => 0
* resolution: => invalid
* needs_tests: => 0
* needs_docs: => 0


Comment:

I think you made a mistake. The URLconf in the block above still uses
`poll_id` rather than `pk`: `url(r'^(?P<poll_id>\d+)/vote/$', views.vote,
name='vote'),`

--
Ticket URL: <https://code.djangoproject.com/ticket/22700#comment:1>

Reply all
Reply to author
Forward
0 new messages