How Can I Copy Cms Pages From A Development Site To A Live Site?
Solution 1:
The discussion you refer to predates the 3.x series. Perhaps doing a dumpdata
for the models associated with the cms
application was the way to go 3 years ago, but, as you discovered, it does not work now.
I actually recommend trying the following steps on a mirror of your live site first so that any surprises can be taken care of ahead of the real operation. If you run into trouble on the mirror, you can take your time figuring the problem. Once you are ready to modify your live site, before you do anything, you should backup your database. Better safe than sorry. Also, the codebase on the site should be updated to reflect your development version before you try moving data around.
You can use these steps:
Inspect your
INSTALLED_APPS
setting and make a list of those apps that are CMS plugins and of the applications these plugins depend on. You may need to consult the installation instructions of some of the plugins to recall what depends on what.Once you have the list you can issue a
dumpdata
command on your development site withcms
and the applications you identified. For my site, I have to do:python manage.py dumpdata --natural-foreign cms filer \ cmsplugin_filer_file cmsplugin_filer_folder cmsplugin_filer_link \ cmsplugin_filer_image cmsplugin_filer_teaser cmsplugin_filer_video \ easy_thumbnails djangocms_text_ckeditor > data.json
If you also have created custom permission settings for Django CMS, you may need to edit
data.json
to remove some or all of the custom settings. In my case I had acms.PageUserGroup
instance that I had created on my dev site. It referred to a group that does not exist on the live site and so I had to remove this instance from thedata.json
dump. Otherwise, theloaddata
command in the next step failed with an integrity error.You then copy
data.json
to your live site and issuepython manage.py loaddata data.json
.If you have any files you've added to your
media
directory on your development site to create your CMS pages, you also need to copy them over to your live site.
I've used the procedure above to move data from my development site to a live site, with no discernible problem.
Caveats
The procedure above is meant to be a one time deal. It won't work if you continue making changes to your development pages and then try to migrate them over to your live site.
I've mentioned issues with permissions in the steps above. You are least likely to run into permission issues if you have
CMS_PERMISSIONS
set toFalse
. If set toTrue
, then you may have to edit your dump like instructed above before loading it on the live site. If you've done heavy customization of the permission scheme and have a whole bunch ofPageUserGroup
instances and a bunch of pages with special permissions, etc., then you are likely to run into major difficulties. I don't know a solution short of undoing all this customization, or editing the dump by hand to make it match your live site. The problem is due to the fact that the procedure above does not dump the authentication models (ofdjango.contrib.auth
). If you are in a situation where you can safely load them on the live site, then adding them to the dump would probably do the trick. However, when you have a live site that has been in production and where the authentication data has changed over time, you cannot just load the authentication models from the development site as this would overwrite some of the records (e.g. "admin"'s password would change to the one stored in the development database).The method above does not move any of the pages' history. It is recorded with
reversion
. If you wanted to move the page's history, you'd have to addreversion
to the list of apps to dump but I'm pretty sure it could have undesirable side-effects: it could also affect the data that reversion records for other apps that use it in the project. (In effect it would change or erase history of other apps.)
Solution 2:
To copy CMS pages from a development site to a live site you could use Django CMS Transfer: https://github.com/django-cms/djangocms-transfer
Django CMS Transfer is a package that allows you to export and import plugin data from a page or a placeholder.
It works pretty well for simple tasks like exporting plugins' content from a page and then importing it to another site. However, it does not support foreign-key relations and won't import or export related data.
The Django CMS Association endorses this project.
Post a Comment for "How Can I Copy Cms Pages From A Development Site To A Live Site?"