Opened 3 weeks ago

Closed 3 weeks ago

Last modified 3 weeks ago

#36636 closed Bug (fixed)

Outdated documentation in set_language() references removed session-based language storage

Reported by: Samriddha Kumar Tripathi Owned by: Dani Fornons
Component: Documentation Version: 5.2
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

The documentation and docstring for django.views.i18n.set_language() contain outdated information about session-based language storage, which was deprecated in Django 3.0 and removed in Django 4.0.

Affected locations:

  1. Docstring in django/views/i18n.py: Current text says: "Redirect to a given URL while setting the chosen language in the session (if enabled) and in a cookie."
  1. Documentation (i18n section): Current text says: "The view expects to be called via the POST method, with a language parameter set in request. If session support is enabled, the view saves the language choice in the user's session. It also saves the language choice in a cookie that is named django_language by default."

The issue:

The actual code in set_language() does NOT save the language to the session. According to the Django 3.0 release notes:

"To limit creation of sessions and hence favor some caching strategies, django.views.i18n.set_language() will stop setting the user's language in the session in Django 4.0. Since Django 2.1, the language is always stored in the LANGUAGE_COOKIE_NAME cookie."

Expected behavior:

Both the docstring and documentation should be updated to remove references to session storage and clarify that the language choice is stored only in the cookie (LANGUAGE_COOKIE_NAME, which defaults to django_language).

Credit: Issue reported by kid_alan_ on Discord.

Change History (7)

comment:1 by Dani Fornons, 3 weeks ago

Owner: set to Dani Fornons
Status: newassigned

comment:2 by Dani Fornons, 3 weeks ago

I’ve opened a PR with the proposed changes, treating it as a draft until the ticket is verified.

comment:3 by Jacob Walls, 3 weeks ago

Triage Stage: UnreviewedAccepted

Thanks, looks like this was missed in d134b0b93ee10a2128c595997cbc6022c4a982f7.

comment:4 by Jacob Walls, 3 weeks ago

Triage Stage: AcceptedReady for checkin

comment:5 by Jacob Walls <jacobtylerwalls@…>, 3 weeks ago

Resolution: fixed
Status: assignedclosed

In 2514857e:

Fixed #36636, Refs #15902 -- Removed session-based storage reference from set_language() docs.

comment:6 by Jacob Walls <jacobtylerwalls@…>, 3 weeks ago

In ec81e680:

[6.0.x] Fixed #36636, Refs #15902 -- Removed session-based storage reference from set_language() docs.

Backport of 2514857e3fae831106832cca8823237801cf2cad from main.

comment:7 by Jacob Walls <jacobtylerwalls@…>, 3 weeks ago

In 2d2e1a6a:

[5.2.x] Fixed #36636, Refs #15902 -- Removed session-based storage reference from set_language() docs.

Backport of 2514857e3fae831106832cca8823237801cf2cad from main.

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