我有一个芹菜任务异步发送电子邮件
from djcelery.common import respects_language @task(ignore_result=True) @respects_language def async_send_activation_email(registration_profile): registration_profile.send_activation_email()
并发送激活电子邮件功能
from django.core import context_processors def send_activation_email(self): variables = { 'some_variable':'something', } context = context_processors.i18n(None) # Allows to easily get all the language information into context. None is passed as the request does not matter for this context_processor. # Subject # Email subject *must not* contain newlines subject = render_to_string( 'user_manager/activation/email_subject.txt', variables, context ) ...
context包含正确的信息(在我的例子中是LANGUAGE ='fr',以及其他语言选项).这是正常的,因为它们由@respects_language
装饰器正确设置.
但无论如何,render_to_string都使用了后备语言.
关于可能发生的事情的任何想法?