更新 Django 站点时如何维护用户数据?
我有一个已经有注册用户的实时 Django 网站。我正在尝试使用与原始网站不同的新版本更新该网站 - 类似的想法但不同的模型。
如何让当前用户留在新网站上?
我听说 South 可能是一个不错的解决方案,但旧网站没有安装它。在这种情况下可以使用南方吗?
感谢您的帮助!
I have a live Django site that already has registered users. I am trying to update the site with a new version that is different from the original site -similar idea but different models.
How can I keep the current users on the new site?
I have heard South may be a good solution, but the old site doesn't have it installed. Is it possible to use South in this case?
Thanks for the help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是 http://south.aeracode.org/docs/convertinganapp.html#转换应用程序
yes http://south.aeracode.org/docs/convertinganapp.html#converting-an-app
+1 向南,但是...
我们需要更多信息!您是否正在对模型进行根本性更改,或者只是在此处或那里添加或删除字段?
South 可以处理一些相当激进的迁移,但您必须编写一些自定义迁移代码。就我个人而言,如果我要添加一个新字段,我会使用 South,但不会用于这种更激进的东西。
如果这是一个大的架构更改,完全重新组织您的站点,那么我只需编写您自己的脚本来读取旧对象并创建新对象。制作生产数据库的副本(通过 pg_dump、mysqldump 等)并将其加载到本地计算机,您可以在其中测试和调试自定义转换脚本。确保您的“旧模型”和“新模型”具有不同的名称,并将所有内容保留在 settings.py 中,以便您始终可以阅读和查看写下一切。
写&测试迁移脚本,工作后,您可以创建另一个更改列表来删除所有旧对象,然后根据需要删除其相应的源代码。
+1 to South, but...
We need more information! Are you doing radical changes to your Models, or just adding or removing fields here or there?
South can handle some pretty radical migrations, but you'll have to write some custom migration code. Personally, I use South if I'm adding a new field, but not for this kind of more radical stuff.
If it's a big Schema change, completely re-organizing your site, then I'd just write your own script to read the old objects, and create the new ones. Make a copy of your production database (via pg_dump, mysqldump, etc.) and load it on to your local machine, where you can test and debug the custom conversion script. Make sure your "old models" and "new models" have different names, and keep everything in your settings.py so that you can always read & write everything.
Write & test the migration script, and after that works, you can create another changelist to delete all the old objects, and then remove their corresponding source code if you want.