Opened 17 years ago

Closed 17 years ago

Last modified 17 years ago

#5764 closed (invalid)

i18n doesn't work on GET-request

Reported by: b23dev@… Owned by: nobody
Component: Uncategorized Version: dev
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

Description

I used this code from the example (http://www.djangoproject.com/documentation/i18n/#the-set-language-redirect-view) 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 by pytechd <pytechd@…>, 17 years ago

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 by James Bennett, 17 years ago

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

comment:3 by b23dev@…, 17 years ago

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>
</form>
Note: See TracTickets for help on using tickets.
Back to Top