summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRamiro Morales <cramm0@gmail.com>2010-10-10 01:59:17 +0000
committerRamiro Morales <cramm0@gmail.com>2010-10-10 01:59:17 +0000
commit4d70df8b7830d32dd06728a12a39df14e07e42be (patch)
treea03a8eea0732525b04c238f9cb3035a4e10d2c53
parenta92da6e80b840ba7874e6faebd54d50be85ab1ae (diff)
[1.2.X] Fixed #12650 -- Don't generate invalid XHTML in the admin, databrowse apps when
the i18n context processor is active. Thanks to Rob Hudson for the report and fix suggestion. Backport of [14104] from trunk git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@14105 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/contrib/admin/templates/admin/base.html2
-rw-r--r--django/contrib/databrowse/templates/databrowse/base.html2
-rw-r--r--tests/regressiontests/admin_views/tests.py30
3 files changed, 32 insertions, 2 deletions
diff --git a/django/contrib/admin/templates/admin/base.html b/django/contrib/admin/templates/admin/base.html
index 4221e2d1a7..30a4e494fa 100644
--- a/django/contrib/admin/templates/admin/base.html
+++ b/django/contrib/admin/templates/admin/base.html
@@ -1,5 +1,5 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" lang="{{ LANGUAGE_CODE }}" xml:lang="{{ LANGUAGE_CODE }}" {% if LANGUAGE_BIDI %}dir="rtl"{% endif %}>
+<html xmlns="http://www.w3.org/1999/xhtml" lang="{{ LANGUAGE_CODE|default:"en-us" }}" xml:lang="{{ LANGUAGE_CODE|default:"en-us" }}" {% if LANGUAGE_BIDI %}dir="rtl"{% endif %}>
<head>
<title>{% block title %}{% endblock %}</title>
<link rel="stylesheet" type="text/css" href="{% block stylesheet %}{% load adminmedia %}{% admin_media_prefix %}css/base.css{% endblock %}" />
diff --git a/django/contrib/databrowse/templates/databrowse/base.html b/django/contrib/databrowse/templates/databrowse/base.html
index a3419851c4..33cac48601 100644
--- a/django/contrib/databrowse/templates/databrowse/base.html
+++ b/django/contrib/databrowse/templates/databrowse/base.html
@@ -1,5 +1,5 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" lang="{{ LANGUAGE_CODE }}" xml:lang="{{ LANGUAGE_CODE }}" {% if LANGUAGE_BIDI %}dir="rtl"{% endif %}>
+<html xmlns="http://www.w3.org/1999/xhtml" lang="{{ LANGUAGE_CODE|default:"en-us" }}" xml:lang="{{ LANGUAGE_CODE|default:"en-us" }}" {% if LANGUAGE_BIDI %}dir="rtl"{% endif %}>
<head>
<title>{% block title %}{% endblock %}</title>
{% block style %}
diff --git a/tests/regressiontests/admin_views/tests.py b/tests/regressiontests/admin_views/tests.py
index 6a4d3975b5..99aa888201 100644
--- a/tests/regressiontests/admin_views/tests.py
+++ b/tests/regressiontests/admin_views/tests.py
@@ -18,6 +18,7 @@ from django.utils.cache import get_max_age
from django.utils.encoding import iri_to_uri
from django.utils.html import escape
from django.utils.translation import get_date_formats, activate, deactivate
+import django.template.context
# local test models
from models import Article, BarAccount, CustomArticle, EmptyModel, \
@@ -2232,3 +2233,32 @@ try:
except ImportError:
pass
+
+class ValidXHTMLTests(TestCase):
+ fixtures = ['admin-views-users.xml']
+ urlbit = 'admin'
+
+ def setUp(self):
+ self._context_processors = None
+ self._use_i18n, settings.USE_I18N = settings.USE_I18N, False
+ if 'django.core.context_processors.i18n' in settings.TEMPLATE_CONTEXT_PROCESSORS:
+ self._context_processors = settings.TEMPLATE_CONTEXT_PROCESSORS
+ cp = list(settings.TEMPLATE_CONTEXT_PROCESSORS)
+ cp.remove('django.core.context_processors.i18n')
+ settings.TEMPLATE_CONTEXT_PROCESSORS = tuple(cp)
+ # Force re-evaluation of the contex processor list
+ django.template.context._standard_context_processors = None
+ self.client.login(username='super', password='secret')
+
+ def tearDown(self):
+ self.client.logout()
+ if self._context_processors is not None:
+ settings.TEMPLATE_CONTEXT_PROCESSORS = self._context_processors
+ # Force re-evaluation of the contex processor list
+ django.template.context._standard_context_processors = None
+ settings.USE_I18N = self._use_i18n
+
+ def testLangNamePresent(self):
+ response = self.client.get('/test_admin/%s/admin_views/' % self.urlbit)
+ self.failIf(' lang=""' in response.content)
+ self.failIf(' xml:lang=""' in response.content)