开发者

How to completely dump the data for Django-CMS

开发者 https://www.devze.com 2022-12-21 05:38 出处:网络
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 env

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 mod开发者_StackOverflow中文版els - 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


Your dumpdata command only dumps the data for the cms app, but each plugin (cms.plugins.text, cms.plugins.picture, etc.) is its own app, and so needs to be added to the command line.

0

精彩评论

暂无评论...
验证码 换一张
取 消