如何安全地从 Django 1.0.2 升级到 1.3.1?
将进行以下工作:
- 卸载 django 1.0.2
- 安装 django 1.3.1
- 启动一个与旧项目同名的“新”项目。
- 手动导入我所有的旧应用程序等。
- 祈祷我没有杀死任何东西。
据推测,版本之间存在一些显着差异,那么这行得通吗? ..有没有一种不那么痛苦(安全)的方法来做到这一点?
Will the following work:
- Un-installing django 1.0.2
- Installing django 1.3.1
- Starting a 'new' project with the same name as the old one.
- Manually import all of my old apps etc.
- Cross my fingers I've not killed anything.
Presumably there are some significant differences between the versions so would that work? ..and is there a less painful (safe) way to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
事情很可能会崩溃——自旧的 1.0 时代以来,Django 发生了很多(好的!)变化。您的第一步实际上应该是阅读升级路径中 Django 每个主要版本的发行说明(特别是“向后不兼容的更改”部分),以了解发生了哪些更改以及您需要更改哪些内容。
您还需要计划首先在开发(而不是生产!)中进行升级 - 您几乎肯定需要在很多地方更新项目,因此您需要离线执行此操作,然后移动更新的代码完成测试后投入生产。
发行说明:
https://docs.djangoproject.com/en/dev/releases/1.1 /
https://docs.djangoproject.com/en/dev/releases/1.2/
https://docs.djangoproject.com/en/dev/releases/1.3/
It is very likely that things will break--there have been a lot of (good!) changes in Django since the old 1.0 days. Your first step really should probably be reading the release notes for each major version of Django along your upgrade path (particularly the "Backwards Incompatible Changes" sections) to get an idea of what changes have happened and what you'll need to change.
You also need to plan to do the upgrade in development (not production!) first--you'll almost certainly need to update your project in quite a few places, so you'll want to do that offline and then move the updated code into production after you've finished testing.
Release Notes:
https://docs.djangoproject.com/en/dev/releases/1.1/
https://docs.djangoproject.com/en/dev/releases/1.2/
https://docs.djangoproject.com/en/dev/releases/1.3/
首先,您绝对应该首先在开发环境中执行此过程。如果需要,创建生产数据库的转储,并将其导入到开发数据库中。
不需要“卸载”Django。我建议您将 site-packages 目录中的
django
文件夹重命名为django_old
之类的名称,然后安装新版本的 Django。使用
runserver
启动您的开发环境,看看会发生什么。运行测试套件以确保您使用的应用程序和第三方应用程序没有任何重大问题。如果一切正常,您就可以在生产机器上重复该过程。老实说,你确实不应该遇到很多问题。 Django 很少弃用任何东西,当弃用任何东西时,在它真正停止运行之前,总会有多个版本的弃用警告。不过,请尽快纠正您收到的任何弃用警告。
First, you should definitely do this process in a development environment first. Create a dump of your production DB if you need it, and import it into your development database.
"Un-installing" Django is unnecessary. I'd recommend simply renaming the
django
folder in your site-packages directory to something likedjango_old
and then install the new version of Django.Start up your development environment with
runserver
and see what happens. Run the testsuite to make sure your apps and third-party apps you're using don't have any major issues.If everything works fine, you can then repeat the process on your production machine. Honestly, you really shouldn't have many problems, though. Django very rarely deprecates anything, and when they do, there's always deprecation warnings for multiple versions, before it actually ceases to function. Correct any deprecation warnings you get as soon as possible though.
是的。 始终使用virtualenv所有您的[新]制作推出,从这个开始。 :)
然后,使用不同版本的 Django(也可能还有其他 Python 库的较新版本)启动并运行新实例的暂存版本并没有什么大不了的。
您可以保持旧版本正常运行,直到您确定已准备好执行升级。
显然,您需要确保在测试时将新版本指向不同的数据库并在不同的端口上运行。除此之外,它应该是美好而简单的。
正如 Michael 所指出的,您肯定会发现您需要从 1.0 到 1.3 进行一些更改,并且您需要先在开发环境中解决这些更改,然后再考虑关于您的生产升级。
一些有用的指针:
Yes. Always use virtualenv for all your [new] production rollouts, starting with this one. :)
Then there's no biggie in having a staging version of the new instance up and running with a different version of Django (and possibly also newer versions of other python libraries too).
You can keep your old version up and running until you're sure you're ready to perform the upgrade.
Obviously you'll need to make sure you're pointing your new version at a different database and running on a different port while testing. Other than that it should be nice and simple.
As noted by Michael, you'll pretty much definitely find that you'll need to make some changes from 1.0->1.3, and you'll want to address those in a development environment first before thinking about your production upgrade.
Couple of useful pointers: