Opened 6 months ago

Last modified 6 months ago

#36254 closed Bug

Documentation 'Selecting the current time zone' code error — at Version 2

Reported by: YQ Owned by:
Component: Documentation Version: dev
Severity: Normal Keywords: timezone items
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by YQ)

ValueError at /set_timezone/
Need 2 values to unpack in for loop; got 6.
Request Method: GET
Request URL: http://127.0.0.1:8000/set_timezone/
Django Version: 5.2b1
Exception Type: ValueError
Exception Value:
Need 2 values to unpack in for loop; got 6.

common_timezones = {
    "London": "Europe/London",
    "Paris": "Europe/Paris",
    "New York": "America/New_York",
}

...

return render(request, "template.html", {"timezones": common_timezones})

...

# template.html
{% for city, tz in timezones %}  # Error : Need 2 values to unpack in for loop; got 6. 
... 

it should be

{% for city, tz in timezones.items %}

https://github.com/django/django/pull/19270

Change History (2)

comment:1 by YQ, 6 months ago

Has patch: set

comment:2 by YQ, 6 months ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top