django-modelstranslation回退原始字段值 [英] django-modelstranslation fallback original field value

查看:203
本文介绍了django-modelstranslation回退原始字段值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个很大的Django应用程序,互联网用户正在积极使用它.我正在尝试将 django-modeltranslation 添加到我的一个应用中.在开发过程中,可以按照以下步骤正常运行

I have a big Django application that is actively used by internet users. I am trying to add django-modeltranslation to one of my apps. In development everything works alright with the following procedure:

  1. 安装django-modeltranslation并进行适当的模型更改.
  2. 为其创建南迁移python manage.py schemamigration myapp --auto
  3. 应用迁移python manage.py migrate myapp
  4. 运行django-modeltranslation 管理命令从原始字段python manage.py update_translation_fields
  5. 填充默认语言
  1. Install django-modeltranslation and do the proper model changes.
  2. Create the South migration for it python manage.py schemamigration myapp --auto
  3. Apply the migration python manage.py migrate myapp
  4. Run django-modeltranslation management command to populate default language from original field python manage.py update_translation_fields

我遇到的问题在第3项和第4项之间.如果我在生产环境中运行迁移,那么转换后的模型将不会显示任何内容给我(我无法停机),直到我运行第4项为止.需要一些时间才能完成.

The problem I have is between item 3 and 4. If I run the migration on production, then the translated model would show no content to the user (I can't have a downtime) until I run number 4, which could take some time to finish.

我想知道是否有一种方法可以将翻译内容还原为该字段的原始内容而无需翻译.此后备广告会转为另一种翻译后备广告,并且可以访问原始版本字段原始.但是,如果不存在转换,我需要将模型字段默认设置为原始字段值.

I would like to know if there is a way to fallback a translation to the original content of the field without translation. This fallbacks to another translation fallback and this access the original field original. But I need the model field to default to the original field value if the translation is not present.

谢谢

推荐答案

  1. 将生产数据库克隆到暂存环境.
  2. 在登台中应用迁移.
  3. 验证所有工作是否都可以在分阶段进行.

  1. Clone the production database to a staging environment.
  2. Apply the migration in staging.
  3. Verify everything works in staging.

然后选择:

a.将网络配置指向暂存状态,随意配置生产,然后重新配置网络(停机时间为0).

a. Point the network configuration to staging, configure production at your leisure and reconfigure the network back (0 downtime).

b.使用所需的软件包实时更新生产环境,并将数据库从登台环境复制到生产环境(最少的停机时间).

b. Update the production environment on live with the required packages and copy the database from staging environment into production (minimal downtime).

这篇关于django-modelstranslation回退原始字段值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆