Code

Opened 7 years ago

Closed 7 years ago

Last modified 7 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: UI/UX:

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.

Attachments (0)

Change History (3)

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

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

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 7 years ago by ubernostrum

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

comment:3 Changed 7 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>
</form>

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.