﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
24601	Template rendering breaks for number in management command due to translation.deactivate_all()	stephanm	nobody	"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
}}}"	Bug	closed	Uncategorized	1.8	Normal	duplicate			Unreviewed	0	0	0	0	0	0
