【问题标题】:django-sitetree how to migrate data to production serverdjango-sitetree 如何将数据迁移到生产服务器
【发布时间】:2013-04-17 10:23:19
【问题描述】:

我正在使用 south 将方案迁移到生产环境。我还使用 django-sitetree 模块在我的站点中显示菜单。

使用命令迁移架构没有问题:

./manage.py schemamigration myApp --freeze sitetree --auto
./manage.py migrate myApp

但是,当我尝试通过命令迁移站点树数据时:

./manage.py datamigration myApp "new_version" --freeze sitetree

它不会生成任何已创建的站点树元素。

【问题讨论】:

    标签: django django-south data-migration django-sitetree


    【解决方案1】:

    好的,经过一些研究并感谢以下来源:Altering database tables in DjangoFixtures and initial data 博客,似乎通过使用带有固定装置的 initial_data.json 文件来传递菜单数据的更好方法。

    1. 在您的 App 文件夹中创建“fixtures”文件夹。

    2. 运行./manage.py dumpdata --format=json --indent=4 sitetree > APP_PATH/fixtures/initial_data.json 如果您希望将更多应用程序的数据迁移到其他环境,可以在命令中添加更多应用程序。

    3. 保存到fixtures/initial_data.json的数据将始终通过运行./manage.py syncdb被插入/替换请记住,如果数据已经存在于DB中,则将被替换,这意味着您不应该转储动态数据。

    还有另一种使用sitetree management command迁移站点树的方法

    # Dump...
    python manage.py sitetreedump > treedump.json
    # Restore...
    python manage.py sitetreeload --mode=replace treedump.json
    

    感谢idle-sign 提供此链接

    【讨论】:

    • 谢谢@idlesign,我最近编辑了我的答案并添加了你的链接。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-01-09
    • 1970-01-01
    • 2020-07-11
    • 1970-01-01
    • 2019-04-23
    • 2016-10-18
    • 1970-01-01
    相关资源
    最近更新 更多