Opened 7 years ago

Last modified 4 years ago

#12794 new Bug

Interaction between sessions and django.views.i18n.set_language causes caching errors

Reported by: alessandro.gudio+bugzilla@… Owned by: nobody
Component: Internationalization Version: 1.1
Severity: Normal Keywords: cache i18n
Cc: alessandro.guido+bugzilla@…, raymond.penners@… Triage Stage: Accepted
Has patch: yes Needs documentation: yes
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

The django.views.i18n.set_language view uses the session to store the language if it is available.
If a user has a session and tries to change the language, this change is reflected only in the variables inside the session storage. Since the headers of following requests won't change, the caching framework cannot detect such change and cached pages in the previous language will be returned.

I suggest always using cookies to store language.

Attachments (1)

cooki18n.patch (3.0 KB) - added by Raymond Penners 5 years ago.
No longer store language in session

Download all attachments as: .zip

Change History (12)

comment:1 Changed 7 years ago by anonymous

Cc: alessandro.guido+bugzilla@… added
Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset

comment:2 Changed 7 years ago by Russell Keith-Magee

Triage Stage: UnreviewedAccepted

comment:3 Changed 5 years ago by Luke Plant

Type: Bug

comment:4 Changed 5 years ago by Luke Plant

Severity: Normal

comment:5 Changed 5 years ago by Luke Plant

Easy pickings: unset

See also #15902

comment:6 Changed 5 years ago by raymond.penners@…

Cc: raymond.penners@… added

comment:7 Changed 5 years ago by raymond.penners@…

For those interested, you can use the following Django app to have the language stored in a cookie as suggested.

https://github.com/pennersr/django-cooki18n

Changed 5 years ago by Raymond Penners

Attachment: cooki18n.patch added

No longer store language in session

comment:8 Changed 5 years ago by Raymond Penners

Has patch: set
UI/UX: unset

I have attached a patch that stops Django from storing the language in the session.

A decision is needed on whether support for storing the language in the session is to be completely dropped, or whether it is to be made configurable via settings. For now, the old behaviour has been put below an "if False:" so that it can be easily reinstantiated.

comment:9 Changed 5 years ago by Ramiro Morales

#16461 was a duplicate, reported similar problems but with browsers caches.

comment:10 Changed 4 years ago by Jannis Leidel

Needs documentation: set
Patch needs improvement: set
Note: See TracTickets for help on using tickets.
Back to Top