如何为Django-CMS完全转储数据[英] How to completely dump the data for Django-CMS

本文是小编为大家收集整理的关于如何为Django-CMS完全转储数据的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

我有一个已经在生产环境中运行的Django-CMS实例.我想将所有与CMS(页面和插件)相关的数据转储,以便将其加载到我的开发环境中.

当我做python manage.py dumpdata cms时,它会丢弃大多数数据,但并非全部.插件的内容均未丢弃.当我查看django -cms源时,我看到插件与其他模型的文件夹不同 - 我敢肯定这与dumpdata的行为有关.

.

有人知道他们将如何实现我要做的事情吗?

感谢您的帮助/答案!

推荐答案

django的内置dump和还原命令在迁移CMS的内容方面正常工作.

要转储CMS的内容,您需要同时包括CMS应用程序以及在DumpData命令中使用的每种插件类型,因此类似于:

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

倾倒您的内容(您只需要应用程序名称,而不是完整的路径,例如cms.plugins.text).

其他推荐答案

这是我使用的过程的更新:

./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;

如果您不删除上面的表

IntegrityError: duplicate key value violates unique constraint django_content_type_app_label_key

,然后:

./manage.py loaddata fixtures/all.json

菲利普

其他推荐答案

对于Djangocms 3.0,语法是相同的,但插件的名称都更改了.要获取所有标准插件:

./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

本文地址:https://www.itbaoku.cn/post/597461.html

问题描述

I have an instance of Django-CMS already running in a production environment. 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.

When I do python manage.py dumpdata cms it dumps most of the data, but not all of it. 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.

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.

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:

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).

其他推荐答案

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. 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