--
Ticket URL: <https://code.djangoproject.com/ticket/21446>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_docs: => 0
* has_patch: 0 => 1
* needs_tests: => 0
* needs_better_patch: => 0
Comment:
I’ve created a pull request: https://github.com/django/django/pull/1923
--
Ticket URL: <https://code.djangoproject.com/ticket/21446#comment:1>
* stage: Unreviewed => Accepted
Comment:
I'd go even further, if there is no redirect parameter required just
return 204. Do all browsers etc support this properly?!
--
Ticket URL: <https://code.djangoproject.com/ticket/21446#comment:2>
* stage: Accepted => Unreviewed
--
Ticket URL: <https://code.djangoproject.com/ticket/21446#comment:3>
Comment (by KJ):
The project I’m currently working on uses Django as an API backend and
AngularJS application as a fronted client to this API. The UI localization
is done using Mozilla’s [http://l20n.org/ L20n project] and language
changing is done on-the-fly, without reloading the page. However there are
some parts of the site which use Django templates (like password change
form), so making an AJAX call to `set_language` is still necessary, but
they are loaded using iframes, so there is no need to perform a redirect.
Not performing a redirect when it is not explicitly requested seems
tempting, but it will be backwards incompatible with the current behaviour
– I guess there may be a significant number of sites which rely on the
fact that `set_language` redirects them to the previous page (captured
from the referer header). Maybe we should check `request.is_ajax()` and if
it is true, omit the redirect unless `next` parameter is set? For old-
style HTML websites it may be still a coarsely correct assumption that a
redirect needs to be performed after changing the language. That way we
can resign from introducing the new `no_redirect` parameter.
204 status code seems to be supported by browsers, according to
http://benramsey.com/blog/2008/05/http-status-204-no-content-and-205
-reset-content/ .
--
Ticket URL: <https://code.djangoproject.com/ticket/21446#comment:4>
Comment (by aaugustin):
This plan sounds good to me.
--
Ticket URL: <https://code.djangoproject.com/ticket/21446#comment:5>
Comment (by KJ):
I’ve updated the pull request accordingly.
--
Ticket URL: <https://code.djangoproject.com/ticket/21446#comment:6>
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/21446#comment:7>
* needs_better_patch: 0 => 1
* easy: 1 => 0
Comment:
I left comments for improvement on PR. Please uncheck "Patch needs
improvement" when you update it, thanks.
--
Ticket URL: <https://code.djangoproject.com/ticket/21446#comment:8>
* needs_better_patch: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/21446#comment:9>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/21446#comment:10>
* status: new => closed
* resolution: => fixed
Comment:
In [changeset:"940b7fd5cbcd743658f741d37b3d7b1766ed1f17" 940b7fd5]:
{{{
#!CommitTicketReference repository=""
revision="940b7fd5cbcd743658f741d37b3d7b1766ed1f17"
Fixed #21446 -- Allowed not performing redirect in set_language view
Thanks Claude Paroz and Tim Graham for polishing the patch.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/21446#comment:11>