Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#5764 closed (invalid)

i18n doesn't work on GET-request

Reported by: b23dev@… Owned by: nobody
Component: Uncategorized Version: master
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


I used this code from the example ( to change between the languages.

With form method="POST" all works fine, with "GET" in the FORM it doesn't change.

Change History (3)

comment:1 Changed 12 years ago by pytechd <pytechd@…>

Resolution: invalid
Status: newclosed

As per BackwardsIncompatibleChanges:

In [6177], the set_language() view was changed to only change the caller's locale if called as a POST request. Previously, a GET request was used. The old behaviour meant that state (the locale used to display the site) could be changed by a GET request, which is against the HTTP specification's recommendations.

Code calling this view must ensure that a POST request is now made, instead of a GET. This means you can no longer use a link to access the view, but must use a form submission of some kind (e.g. a button).

comment:2 Changed 12 years ago by James Bennett

As per the documentation you linked in your ticket: "The view expects to be called via the POST method".

comment:3 Changed 12 years ago by b23dev@…

Yes right. I was only confused, because a old project where I changed the language over a <a href="/language/setlang/?language=it"> (GET) doesn't work anymore.

Maybe this code to send a <form> with POST over <a href> could be useful for someone.

<form action="/language/setlang/" method="POST" name="Form_it">
<input name="next" type="hidden" value="/it/start/" />
<input type="hidden" name="language" value="it">
<a href="#" onclick="document.Form_it.submit();">it</a>
Note: See TracTickets for help on using tickets.
Back to Top