如何将CMS页面从开发站点复制到实时站点? [英] How can I copy CMS pages from a development site to a live site?

查看:117
本文介绍了如何将CMS页面从开发站点复制到实时站点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经将Django CMS整合到已经生产了一年多的Django项目中。作为我开发活动的一部分,在我添加Django CMS之前,我已将CMS页面转换成以前是静态内容的页面。我的开发数据库现在包含我想要复制到实时网站的页面,而不是要求项目人员在现场网站上重新创建这些页面。

I've been integrating Django CMS to a Django project that has been in production already for over a year. As part of my development activities, I've converted to CMS pages those pages that used to be static content before I added Django CMS. My development database now contains pages that I would like to copy to the live site rather than require that project staff recreate these pages on the live site.

我已经搜索过Django CMS文档,但没有找到一个命令。我也搜索了有关github的问题,以及关于SO和Django CMS的Google群组的问题。我唯一发现的是这个讨论, 3年前。讨论使用 dumpdata 转储 cms 模型。我试过了转储包含有关页面的信息(例如,创建页面的人,何时),但不包含页面的内容

I have searched the Django CMS documentation but did not find a command for this. I've also searched the issues on github, the questions on SO and the Django CMS google groups. The only thing I've found is this discussion from 3 years ago. The discussion mentions using dumpdata to dump the cms models. I've tried it. The dump contains information about the pages (for instance, who created the page and when) but it does not contain the contents of the pages.

实时网站具有必须保留的数据。因此,我无法在开发站点上执行数据库级转储,并在实时站点上进行还原,因为这将擦除或覆盖实时站点上已存在的数据。

The live site has data that must be preserved. So I cannot perform a database level dump on the development site and restore on the live site, as this would erase or overwrite data that already exists on the live site.

I '使用Django 1.7和Django CMS 3.1.0。

I'm using Django 1.7 and Django CMS 3.1.0.

推荐答案

你提到的讨论早于3.x系列。对于与 cms 应用程序相关联的模型,可能会执行 c> dumpdata 3年前,但是,正如您所发现的,现在不起作用。

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.

您可以使用以下步骤:


  1. 检查您的 INSTALLED_APPS 设置并列出CMS插件和这些插件所依赖的应用程序的应用程序。您可能需要查阅一些插件的安装说明,以回忆哪些内容取决于什么。

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

一旦您有列表,您可以发出一个您的开发网站上使用 cms 和您确定的应用程序的dumpdata 命令。对于我的网站,我必须做:

Once you have the list you can issue a dumpdata command on your development site with cms 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


  • 如果您还创建了Django CMS的自定义权限设置, >可能需要编辑 data.json 删除部分或全部自定义设置。在我的情况下,我已经在我的开发网站上创建了一个 cms.PageUserGroup 实例。它引用了一个在实际网站上不存在的组,因此我不得不从 data.json 转储中删除此实例。否则,下一步中的 loaddata 命令失败,导致完整性错误。

  • 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 a cms.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 the data.json dump. Otherwise, the loaddata command in the next step failed with an integrity error.

    然后复制 data.json 到您的实际网站,并发行 python manage.py loaddata data.json

    You then copy data.json to your live site and issue python manage.py loaddata data.json.

    如果您有任何文件添加到开发网站上的 media 目录中,以创建CMS页面,那么您也需要将其复制到您的实际网站。

    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.


    1. 上述程序是为了一次交易。如果您继续对开发页面进行更改,然后尝试将其迁移到现场网站,那将不起作用。

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

    我已经提到了上述步骤中的权限。如果您有 CMS_PERMISSIONS 设置为 False ,则您最不可能遇到权限问题。如果设置为 True ,则可能必须按照上述指示编辑您的转储,然后才能将其加载到实时网站上。如果您对许可方案做了大量定制,并且拥有一大堆 PageUserGroup 实例和一堆具有特殊权限的页面,那么您很可能会运行成为重大困难。我不知道一个解决方案,不能撤消所有这些定制,手动编辑转储,使其与您的现场网站匹配。问题是由于上面的过程不转储认证模型( django.contrib.auth )。如果您处于某种情况,您可以将安全地将它们加载到实时站点上,那么将它们添加到转储中可能会做到这一点。但是,当您有一个已经在生产中的实时站点以及认证数据随时间发生变化的地方,您不能只从加载开发站点的认证模型,因为这会覆盖一些记录(例如admin的密码将更改为存储在开发数据库中的一个。)

    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 to False. If set to True, 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 of PageUserGroup 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 (of django.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).

    上述方法不会移动任何页面的历史记录。它被记录为 reversion 。如果您想移动页面的历史记录,您必须将 reversion 添加到要转储的应用程序列表中,但我很确定它可能会有不良副作用:它也可能影响在项目中使用它的其他应用程序恢复记录的数据。 (实际上它会更改或删除其他应用程序的历史记录。)

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

    这篇关于如何将CMS页面从开发站点复制到实时站点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆