Should I try to actually upgrade my existing app, or just rewrite it mostly from scratch, saving what pieces (templates, etc) I can?
我应该尝试实际升级我现有的应用程序,还是只是从头开始重写它,保存哪些部分(模板等)我可以?
5 个解决方案
#1
6
Although this depends on what you're doing, most applications should be able to just upgrade and then fix everything that breaks. In my experience, the main things that I've had to fix after an upgrade are
虽然这取决于你正在做什么,但大多数应用程序应该只能升级然后修复所有破坏的东西。根据我的经验,升级后我必须解决的主要问题是
-
Changes to some of the funky stuff with models, such as the syntax for following foreign keys.
使用模型更改某些时髦的东西,例如以下外键的语法。
-
A small set of template changes, most notably auto-escaping.
一小组模板更改,最明显的是自动转义。
-
Anything that depends on the specific structure of Django's internals. This shouldn't be an issue unless you're doing stuff like dynamically modifying Django internals to change their behavior in a way that's necessary/convenient for your project.
任何取决于Django内部特定结构的东西。这不应该是一个问题,除非你正在做一些事情,比如动态修改Django内部,以一种对项目必要/方便的方式改变他们的行为。
To summarize, unless you're doing a lot of really weird and/or complex stuff, a simple upgrade should be relatively painless and only require a few changes.
总而言之,除非你做了很多非常奇怪和/或复杂的事情,否则简单的升级应该相对轻松,只需要做一些改动。
#2
3
Upgrade. For me it was very simple: change __str__()
to __unicode__()
, write basic admin.py
, and done. Just start running your app on 1.0, test it, and when you encounter an error use the documentation on backwards-incompatible changes to see how to fix the issue.
升级。对我来说非常简单:将__str __()更改为__unicode __(),编写基本的admin.py,然后完成。只需开始在1.0上运行您的应用程序,对其进行测试,并在遇到错误时使用有关向后兼容的更改的文档,以了解如何解决该问题。
#3
2
Just upgrade your app. The switch from 0.96 to 1.0 was huge, but in terms of Backwards Incompatible changes I doubt your app even has 10% of them.
只需升级您的应用。从0.96到1.0的转换是巨大的,但就Backwards不兼容的变化而言,我怀疑你的应用程序甚至有10%。
I was on trunk before Django 1.0 so I the transition for me was over time but even then the only major things I had to change were newforms, newforms-admin, str() to unicode() and maxlength to max_length
我在Django 1.0之前的主干上,所以我对我的过渡是随着时间的推移但是即便如此,我必须改变的唯一主要事情是newforms,newforms-admin,str()到unicode()和maxlength到max_length
Most of the other changes were new features or backend rewrites or stuff that as someone who was building basic websites did not even get near.
大多数其他更改都是新功能或后端重写或者正在建立基本网站的人甚至没有接近的东西。
#4
1
Only simplest sites are easy to upgrade.
只有最简单的网站才能轻松升级。
Expect real pain if your site happen to be for non-ASCII part of the world (read: anywhere outside USA and UK). The most painful change in Django was switching from bytestrings to unicode objects internally - now you have to find all places where you use bytestrings and change this to unicode. Worst case is the template rendering, you'll never know you forgot to change one variable until you get UnicodeError.
如果您的网站恰好适用于非ASCII部分,那么您会感到非常痛苦(阅读:美国和英国以外的任何地方)。 Django中最痛苦的变化是在内部从字节串切换到unicode对象 - 现在你必须找到你使用字节串的所有地方并将其改为unicode。最糟糕的情况是模板渲染,你永远不会知道你忘记更改一个变量,直到你得到UnicodeError。
Other notable thing: manipulators (oldforms) have gone and you have no other way than to rewrite all parts with forms (newforms).
其他值得注意的事情:操纵器(oldforms)已经消失,除了用表格(newforms)重写所有部分之外别无他法。
If this is your case and your project is larger than 2-3 apps, I'd be rather reluctant to upgrade until really necessary.
如果这是你的情况,你的项目大于2-3个应用程序,我会非常不愿意升级,直到真的有必要。
#5
1
We upgraded in a multi step process and I'm quite happy with that. The application in Question was about 100.000 LoC and running several core business functions with lot's of interfacing to legacy systems. We worked like that:
我们在一个多步骤的过程中进行了升级,我对此非常满意。问题中的应用程序大约是100.000 LoC并运行几个核心业务功能,其中很多都与遗留系统接口。我们这样工作:
- Update to django 0.97-post unicode merge. Fix all the unicode issues
- 更新到django 0.97-post unicode merge。修复所有unicode问题
- refactor the application into reusable apps, add tests. That left us with 40.000 LoC in the main application/Project
- 将应用程序重构为可重用的应用程序,添加测试。这使我们在主要应用程序/项目中获得了40.000 LoC
- Upgrade to django 0.97-post autoexcape merge. Fix auto escaping in the reusable apps created in 3. Then fix the remaining auto-escaping issues in the mian application.
- 升级到django 0.97-post autoexcape merge。修复在3中创建的可重用应用程序中的自动转义。然后在mian应用程序中修复剩余的自动转义问题。
- Upgrade to 1.0. What was left was mostly fixing the admin stuff.
- 升级到1.0。剩下的就是修复管理员的东西。
The whole thing took about 6 months where we where running a legacy production branch on our servers while porting an other branch to 1.0. While doing so we also where adding features to the production branch.
整个过程花费了大约6个月的时间,我们在服务器上运行遗留生产分支,同时将另一个分支移植到1.0。在这样做的同时,我们还在为生产分支添加功能。
The final merge was much less messy than expected and took about a week for 4 coders merging, reviewing, testing and fixing. We then rolled out, and for about a week got bitten by previously unexpected bugs.
最终的合并比预期的要简单得多,并且需要大约一周时间才能完成4个编码器的合并,审查,测试和修复。然后我们推出了大约一个星期,被先前意想不到的错误所困扰。
All in all I'm quite satisfied with the outcome. We have a much better codebase now for further development.
总而言之,我对结果非常满意。我们现在有更好的代码库用于进一步开发。
#1
6
Although this depends on what you're doing, most applications should be able to just upgrade and then fix everything that breaks. In my experience, the main things that I've had to fix after an upgrade are
虽然这取决于你正在做什么,但大多数应用程序应该只能升级然后修复所有破坏的东西。根据我的经验,升级后我必须解决的主要问题是
-
Changes to some of the funky stuff with models, such as the syntax for following foreign keys.
使用模型更改某些时髦的东西,例如以下外键的语法。
-
A small set of template changes, most notably auto-escaping.
一小组模板更改,最明显的是自动转义。
-
Anything that depends on the specific structure of Django's internals. This shouldn't be an issue unless you're doing stuff like dynamically modifying Django internals to change their behavior in a way that's necessary/convenient for your project.
任何取决于Django内部特定结构的东西。这不应该是一个问题,除非你正在做一些事情,比如动态修改Django内部,以一种对项目必要/方便的方式改变他们的行为。
To summarize, unless you're doing a lot of really weird and/or complex stuff, a simple upgrade should be relatively painless and only require a few changes.
总而言之,除非你做了很多非常奇怪和/或复杂的事情,否则简单的升级应该相对轻松,只需要做一些改动。
#2
3
Upgrade. For me it was very simple: change __str__()
to __unicode__()
, write basic admin.py
, and done. Just start running your app on 1.0, test it, and when you encounter an error use the documentation on backwards-incompatible changes to see how to fix the issue.
升级。对我来说非常简单:将__str __()更改为__unicode __(),编写基本的admin.py,然后完成。只需开始在1.0上运行您的应用程序,对其进行测试,并在遇到错误时使用有关向后兼容的更改的文档,以了解如何解决该问题。
#3
2
Just upgrade your app. The switch from 0.96 to 1.0 was huge, but in terms of Backwards Incompatible changes I doubt your app even has 10% of them.
只需升级您的应用。从0.96到1.0的转换是巨大的,但就Backwards不兼容的变化而言,我怀疑你的应用程序甚至有10%。
I was on trunk before Django 1.0 so I the transition for me was over time but even then the only major things I had to change were newforms, newforms-admin, str() to unicode() and maxlength to max_length
我在Django 1.0之前的主干上,所以我对我的过渡是随着时间的推移但是即便如此,我必须改变的唯一主要事情是newforms,newforms-admin,str()到unicode()和maxlength到max_length
Most of the other changes were new features or backend rewrites or stuff that as someone who was building basic websites did not even get near.
大多数其他更改都是新功能或后端重写或者正在建立基本网站的人甚至没有接近的东西。
#4
1
Only simplest sites are easy to upgrade.
只有最简单的网站才能轻松升级。
Expect real pain if your site happen to be for non-ASCII part of the world (read: anywhere outside USA and UK). The most painful change in Django was switching from bytestrings to unicode objects internally - now you have to find all places where you use bytestrings and change this to unicode. Worst case is the template rendering, you'll never know you forgot to change one variable until you get UnicodeError.
如果您的网站恰好适用于非ASCII部分,那么您会感到非常痛苦(阅读:美国和英国以外的任何地方)。 Django中最痛苦的变化是在内部从字节串切换到unicode对象 - 现在你必须找到你使用字节串的所有地方并将其改为unicode。最糟糕的情况是模板渲染,你永远不会知道你忘记更改一个变量,直到你得到UnicodeError。
Other notable thing: manipulators (oldforms) have gone and you have no other way than to rewrite all parts with forms (newforms).
其他值得注意的事情:操纵器(oldforms)已经消失,除了用表格(newforms)重写所有部分之外别无他法。
If this is your case and your project is larger than 2-3 apps, I'd be rather reluctant to upgrade until really necessary.
如果这是你的情况,你的项目大于2-3个应用程序,我会非常不愿意升级,直到真的有必要。
#5
1
We upgraded in a multi step process and I'm quite happy with that. The application in Question was about 100.000 LoC and running several core business functions with lot's of interfacing to legacy systems. We worked like that:
我们在一个多步骤的过程中进行了升级,我对此非常满意。问题中的应用程序大约是100.000 LoC并运行几个核心业务功能,其中很多都与遗留系统接口。我们这样工作:
- Update to django 0.97-post unicode merge. Fix all the unicode issues
- 更新到django 0.97-post unicode merge。修复所有unicode问题
- refactor the application into reusable apps, add tests. That left us with 40.000 LoC in the main application/Project
- 将应用程序重构为可重用的应用程序,添加测试。这使我们在主要应用程序/项目中获得了40.000 LoC
- Upgrade to django 0.97-post autoexcape merge. Fix auto escaping in the reusable apps created in 3. Then fix the remaining auto-escaping issues in the mian application.
- 升级到django 0.97-post autoexcape merge。修复在3中创建的可重用应用程序中的自动转义。然后在mian应用程序中修复剩余的自动转义问题。
- Upgrade to 1.0. What was left was mostly fixing the admin stuff.
- 升级到1.0。剩下的就是修复管理员的东西。
The whole thing took about 6 months where we where running a legacy production branch on our servers while porting an other branch to 1.0. While doing so we also where adding features to the production branch.
整个过程花费了大约6个月的时间,我们在服务器上运行遗留生产分支,同时将另一个分支移植到1.0。在这样做的同时,我们还在为生产分支添加功能。
The final merge was much less messy than expected and took about a week for 4 coders merging, reviewing, testing and fixing. We then rolled out, and for about a week got bitten by previously unexpected bugs.
最终的合并比预期的要简单得多,并且需要大约一周时间才能完成4个编码器的合并,审查,测试和修复。然后我们推出了大约一个星期,被先前意想不到的错误所困扰。
All in all I'm quite satisfied with the outcome. We have a much better codebase now for further development.
总而言之,我对结果非常满意。我们现在有更好的代码库用于进一步开发。