2013-04-24 44 views
1

。另外我使用的是Django的sitetree模块,以显示我的网站的菜单。Django的sitetree如何我使用<strong>南</strong>迁移计划,以生产将数据迁移到生产服务器

没有与架构迁移没有问题,通过使用命令:

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

然而,当我试图通过命令将sitetree数据迁移:

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

它不会产生任何的创建了sitetree元素。

回答

1

好,一些研究,并感谢这个来源后:Altering database tables in DjangoFixtures and initial data博客,似乎是更好的方式来使用initial_data.json文件与夹具通过菜单数据。

  1. 在App文件夹内创建“夹具”文件夹。

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

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

还有其他方式使用迁移sitetree sitetree management command

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

谢谢idle-sign该链接

+0

NB:https://django-sitetree.readthedocs.org/en /latest/management.html – 2013-06-04 15:22:28

+0

谢谢@idlesign,我最近编辑了我的答案并添加了你的链接。 – Kostanos 2013-06-04 16:28:17