Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #18700 -- Added URL reversal for i18n set_language view.

  • Loading branch information...
commit 10f979fd92000de1ac9713351f5cb749e2cbca03 1 parent b496be3
@DrMeers DrMeers authored
View
4 django/conf/urls/i18n.py
@@ -1,5 +1,5 @@
from django.conf import settings
-from django.conf.urls import patterns
+from django.conf.urls import patterns, url
from django.core.urlresolvers import LocaleRegexURLResolver
def i18n_patterns(prefix, *args):
@@ -16,5 +16,5 @@ def i18n_patterns(prefix, *args):
urlpatterns = patterns('',
- (r'^setlang/$', 'django.views.i18n.set_language'),
+ url(r'^setlang/$', 'django.views.i18n.set_language', name='set_language'),
)
View
2  docs/topics/i18n/translation.txt
@@ -1272,7 +1272,7 @@ Here's example HTML template code:
.. code-block:: html+django
- <form action="/i18n/setlang/" method="post">
+ <form action="{% url 'set_language' %}" method="post">
{% csrf_token %}
<input name="next" type="hidden" value="{{ redirect_to }}" />
<select name="language">
View
4 tests/regressiontests/views/tests/i18n.py
@@ -5,6 +5,7 @@
from os import path
from django.conf import settings
+from django.core.urlresolvers import reverse
from django.test import TestCase
from django.utils.translation import override, activate, get_language
from django.utils.text import javascript_quote
@@ -23,6 +24,9 @@ def test_setlang(self):
self.assertRedirects(response, 'http://testserver/views/')
self.assertEqual(self.client.session['django_language'], lang_code)
+ def test_setlang_reversal(self):
+ self.assertEqual(reverse('set_language'), '/views/i18n/setlang/')
+
def test_jsi18n(self):
"""The javascript_catalog can be deployed with language settings"""
saved_lang = get_language()
Please sign in to comment.
Something went wrong with that request. Please try again.