tags:

views:

585

answers:

5

Should I try to actually upgrade my existing app, or just rewrite it mostly from scratch, saving what pieces (templates, etc) I can?

+3  A: 

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.

John Millikin
+5  A: 

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

  1. Changes to some of the funky stuff with models, such as the syntax for following foreign keys.

  2. A small set of template changes, most notably auto-escaping.

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

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.

Eli Courtwright
Don't forget admin and forms changes. Those are Important. Admin isn't difficult. Forms, however, can be killer.
S.Lott
+2  A: 

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.

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

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.

Bart
+1  A: 

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.

Other notable thing: manipulators (oldforms) have gone and you have no other way than to rewrite all parts with forms (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.

zgoda
+1  A: 

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:

  1. Update to django 0.97-post unicode merge. Fix all the unicode issues
  2. refactor the application into reusable apps, add tests. That left us with 40.000 LoC in the main application/Project
  3. 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.
  4. Upgrade to 1.0. What was left was mostly fixing the admin stuff.

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.

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.

All in all I'm quite satisfied with the outcome. We have a much better codebase now for further development.

mdorseif