Opened 10 years ago

Closed 10 years ago

#14088 closed (invalid)

Possible typo in Tutorial page #4

Reported by: Dustin Farris Owned by: nobody
Component: Documentation Version: master
Severity: Keywords: Dev Tutorial
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


Following the introductory tutorial:

The example showing the view() function calls the reverse() function passing a tuple as the "args" argument. This seemed to generate the following error from Django:

"reverse() argument after * must be a sequence, not long"

Fiddling with the code, I realized that reverse() seemed to expect a list for "args", not a tuple. Changing the code to ... , args=[])) cleared the error.

Change History (1)

comment:1 Changed 10 years ago by Karen Tracey

Resolution: invalid
Status: newclosed

Sounds like you did not include the trailing comma in the tuple. Note the doc has, for example:

return HttpResponseRedirect(reverse('poll_results', args=(,)))

The comma after is required for the single-element tuple to be recognized by Python as a tuple, and thus a sequence. This is a standard Python gotcha, see:

(If the trailing comma is missing some place on that page, please point it out exactly; I'm not seeing any missing commas for the args to reverse.)

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