[Django] #21446: Add possibility to not perform redirect in set_language view

12 views
Skip to first unread message

Django

unread,
Nov 15, 2013, 11:00:17 AM11/15/13
to django-...@googlegroups.com
#21446: Add possibility to not perform redirect in set_language view
--------------------------------------+--------------------
Reporter: KJ | Owner: KJ
Type: New feature | Status: new
Component: Internationalization | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------------+--------------------
In `set_language` view, it should be possible to not perform redirect
after request is made. Instead, a 204 status code could be returned. While
performing a redirect was a reasonable behaviour in old times of HTML
apps, for many AJAX applications it may be unnecessary and even
uncomfortable if there is no good page become a redirect target.

--
Ticket URL: <https://code.djangoproject.com/ticket/21446>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Nov 15, 2013, 11:04:07 AM11/15/13
to django-...@googlegroups.com
#21446: Add possibility to not perform redirect in set_language view
-------------------------------------+-------------------------------------

Reporter: KJ | Owner: KJ
Type: New feature | Status: new
Component: | Version: master
Internationalization | Resolution:
Severity: Normal | Triage Stage:
Keywords: | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by KJ):

* 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>

Django

unread,
Nov 29, 2013, 10:14:39 AM11/29/13
to django-...@googlegroups.com
#21446: Add possibility to not perform redirect in set_language view
--------------------------------------+------------------------------------

Reporter: KJ | Owner: KJ
Type: New feature | Status: new
Component: Internationalization | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by apollo13):

* 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>

Django

unread,
Nov 29, 2013, 10:15:51 AM11/29/13
to django-...@googlegroups.com
#21446: Add possibility to not perform redirect in set_language view
-------------------------------------+-------------------------------------

Reporter: KJ | Owner: KJ
Type: New feature | Status: new
Component: | Version: master
Internationalization | Resolution:
Severity: Normal | Triage Stage:
Keywords: | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by apollo13):

* stage: Accepted => Unreviewed


--
Ticket URL: <https://code.djangoproject.com/ticket/21446#comment:3>

Django

unread,
Nov 29, 2013, 11:05:59 AM11/29/13
to django-...@googlegroups.com
#21446: Add possibility to not perform redirect in set_language view
-------------------------------------+-------------------------------------

Reporter: KJ | Owner: KJ
Type: New feature | Status: new
Component: | Version: master
Internationalization | Resolution:
Severity: Normal | Triage Stage:
Keywords: | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

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>

Django

unread,
Nov 29, 2013, 11:08:37 AM11/29/13
to django-...@googlegroups.com
#21446: Add possibility to not perform redirect in set_language view
-------------------------------------+-------------------------------------

Reporter: KJ | Owner: KJ
Type: New feature | Status: new
Component: | Version: master
Internationalization | Resolution:
Severity: Normal | Triage Stage:
Keywords: | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by aaugustin):

This plan sounds good to me.

--
Ticket URL: <https://code.djangoproject.com/ticket/21446#comment:5>

Django

unread,
Nov 29, 2013, 1:47:42 PM11/29/13
to django-...@googlegroups.com
#21446: Add possibility to not perform redirect in set_language view
-------------------------------------+-------------------------------------

Reporter: KJ | Owner: KJ
Type: New feature | Status: new
Component: | Version: master
Internationalization | Resolution:
Severity: Normal | Triage Stage:
Keywords: | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by KJ):

I’ve updated the pull request accordingly.

--
Ticket URL: <https://code.djangoproject.com/ticket/21446#comment:6>

Django

unread,
Dec 2, 2013, 8:58:32 AM12/2/13
to django-...@googlegroups.com
#21446: Add possibility to not perform redirect in set_language view
--------------------------------------+------------------------------------

Reporter: KJ | Owner: KJ
Type: New feature | Status: new
Component: Internationalization | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by aaugustin):

* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/21446#comment:7>

Django

unread,
Jun 5, 2014, 7:58:26 PM6/5/14
to django-...@googlegroups.com
#21446: Add possibility to not perform redirect in set_language view
--------------------------------------+------------------------------------

Reporter: KJ | Owner: KJ
Type: New feature | Status: new
Component: Internationalization | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by timo):

* 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>

Django

unread,
Mar 28, 2016, 1:40:28 PM3/28/16
to django-...@googlegroups.com
#21446: Add possibility to not perform redirect in set_language view
--------------------------------------+------------------------------------

Reporter: KJ | Owner: KJ
Type: New feature | Status: new
Component: Internationalization | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by claudep):

* needs_better_patch: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/21446#comment:9>

Django

unread,
Mar 28, 2016, 7:18:52 PM3/28/16
to django-...@googlegroups.com
#21446: Add possibility to not perform redirect in set_language view on AJAX
requests
-------------------------------------+-------------------------------------

Reporter: KJ | Owner: KJ
Type: New feature | Status: new
Component: | Version: master
Internationalization |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/21446#comment:10>

Django

unread,
Mar 29, 2016, 4:17:22 PM3/29/16
to django-...@googlegroups.com
#21446: Add possibility to not perform redirect in set_language view on AJAX
requests
-------------------------------------+-------------------------------------
Reporter: KJ | Owner: KJ
Type: New feature | Status: closed
Component: | Version: master
Internationalization |
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Claude Paroz <claude@…>):

* 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>

Reply all
Reply to author
Forward
0 new messages