#24601: Template rendering breaks for number in management command due to
translation.deactivate_all()
-------------------------------+--------------------
Reporter: stephanm | Owner: nobody
Type: Bug | Status: new
Component: Uncategorized | Version: 1.8
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
In django 1.8 an old management command does not work anymore.
It stumbles over the number, because in
{{{django/core/management/base.py}}} on line 403
{{{translation.deactivate_all()}}} is called, and later
{{{ _active.value = gettext_module.NullTranslations() }}}
is set.
At least, I found a workaround by setting an explicit language.
Here is the test class to reproduce (if you set: {{{ ACTIVATE_WORKAROUND =
True}}} it will work).
{{{#!py
# -*- coding: utf-8 -*-
from django.core.management.base import BaseCommand
from django.template import Context, Template
txt = " {{number}} {{text}}"
class Command(BaseCommand):
def handle(self, *args, **options):
ACTIVATE_WORKAROUND = False
if ACTIVATE_WORKAROUND:
from django.utils import translation
translation.activate("de")
t = Template(txt)
par = {'number': 9009, 'text': 'text', }
c = Context(par)
s = t.render(c)
print s
}}}
To reproduce please unzip website.zip
and run:
{{{
website> manage.py myapp_test
}}}
You will get a lengthy output whichs ends with:
{{{
...
File "D:\Programme\python27\lib\site-packages\django\utils\lru_cache.py",
line 125, in wrapper
result = user_function(*args, **kwds)
File "D:\Programme\python27\lib\site-
packages\django\utils\translation\trans_real.py", line 409, in
check_for_language
if not language_code_re.search(lang_code):
TypeError: expected string or buffer
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/24601>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/051.a998eca91a7ddf97bafc90184333fa02%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.