Opened 5 years ago

Closed 5 years ago

#14088 closed (invalid)

Possible typo in Tutorial page #4

Reported by: dustin 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: UI/UX:


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 5 years ago by kmtracey

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

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