以编程方式调用 call_command('dumpdata') 后忽略语言设置
我目前正在以编程方式调用 dumpdata 以从我的 django 应用程序导出数据。
from django.core.management import call_command
# and various other imports not directly relevant
response = HttpResponse(mimetype='application/json', )
response['Content-Disposition'] = "filename=%s" % backup_name
sys.stdout = response
call_command('dumpdata')
导出效果很好(如果有点慢),但之后 settings.LANGUAGE_CODE 被忽略,所有页面都恢复为原始语言英语。有什么想法为什么会发生这种情况吗?
我正在使用以下内容: -Python 2.7 - 姜戈 1.3 - Rosetta 用于管理语言翻译
I'm currently programmatically calling dumpdata to export the data from my django app.
from django.core.management import call_command
# and various other imports not directly relevant
response = HttpResponse(mimetype='application/json', )
response['Content-Disposition'] = "filename=%s" % backup_name
sys.stdout = response
call_command('dumpdata')
The export works well (if a tad slow) but afterwards settings.LANGUAGE_CODE is ignored and all pages revert to back to the original language English. Any ideas why this is happening?
I'm using the following:
- Python 2.7
- Django 1.3
- Rosetta for managing language translations
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这可能是由 django.core.management.base.BaseCommand 对象中的代码引起的。代码中的解释是:
执行实际语言切换的代码是:
This is likely caused by code in the
django.core.management.base.BaseCommand
object. The explanation in the code is:The code which does the actual language switch is: