简体   繁体   English

如何完全转储Django-CMS的数据

[英]How to completely dump the data for Django-CMS

I have an instance of Django-CMS already running in a production environment. 我有一个已经在生产环境中运行的Django-CMS实例。 I would like to dump all the data related to the CMS (PAGES and PLUGINS) so that I may load it back into my development environment. 我想转储与CMS相关的所有数据(PAGES和PLUGINS),以便我可以将其加载回我的开发环境。

When I do python manage.py dumpdata cms it dumps most of the data, but not all of it. 当我执行python manage.py dumpdata cms它会转储大部分数据,但不是全部数据。 None of the content for the plugins is dumped. 没有插入插件的内容。 When I look at the django-cms source, I see that the plugins are organized in a different folder than the rest of the models - I'm sure this has something to do with the behavior of dumpdata . 当我查看django-cms源代码时,我发现插件组织在与其他模型不同的文件夹中 - 我确信这与dumpdata的行为有关。

Does anyone know how they would achieve what I am trying to do? 有谁知道他们将如何实现我想做的事情?

Thanks for your help/answers! 感谢您的帮助/解答!

Django's built in dump and restore commands work well for migrating the contents of the CMS. Django内置的转储和恢复命令可以很好地迁移CMS的内容。

To dump the contents of the CMS, you need to include both the cms app as well as each of the plugin types you are using in the dumpdata command, so something like: 要转储CMS的内容,您需要同时包含cms应用程序以及您在dumpdata命令中使用的每个插件类型,例如:

manage.py dumpdata cms text picture link file [other plugin types] > cms_export.json

to dump your content (you just need the app name, not the full path, like cms.plugins.text ). 转储您的内容(您只需要应用程序名称,而不是完整路径,如cms.plugins.text )。

Here's an update to the procedure I use: 这是我使用的程序的更新:

./manage.py dumpdata >fixtures/all.json

psql
DROP DATABASE [DBNAME];
createdb -T template_postgis [DBNAME]

./manage.py syncdb

psql [DBNAME]

delete from auth_group_permissions; delete from auth_permission; delete from django_admin_log; delete from django_content_type;

If you don't delete the tables above you'll get this error when loading the fixtures: 如果你不删除上面的表格,加载灯具时会出现这个错误:

IntegrityError: duplicate key value violates unique constraint django_content_type_app_label_key

And then: 然后:

./manage.py loaddata fixtures/all.json

Philipp 菲利普

For DjangoCMS 3.0, the syntax is the same but the names of the plugins have all changed. 对于DjangoCMS 3.0,语法是相同的,但插件的名称都已更改。 To get all standard plugins: 要获得所有标准插件:

./manage.py dumpdata cms djangocms_column djangocms_file djangocms_flash djangocms_googlemap djangocms_inherit djangocms_link djangocms_picture djangocms_style djangocms_teaser djangocms_text_ckeditor djangocms_video > cms_export.json

您的dumpdata命令仅转储cms应用程序的数据,但每个插件( cms.plugins.textcms.plugins.picture等)都是它自己的应用程序,因此需要添加到命令行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM