What is the best way to upgrade from Django 0.96 to 1.0?

Should I try to actually upgrade an existing application or just rewrite it mostly from scratch so that I can save what parts (templates, etc.)?

+7
python django
source share
5 answers

Although it depends on what you are doing, most applications should be able to just update and then fix everything that breaks. In my experience, the main things that I had to fix after the update,

  • Changes some funky models, such as the syntax for the following foreign keys.

  • A small set of template changes, primarily automatic escaping.

  • Everything that depends on the specific structure of the internal components of Django. This should not be a problem unless you do things like dynamically modify the internal components of Django to change your behavior so that it is necessary / convenient for your project.

To summarize, if you are not doing a lot of really strange and / or complicated things, a simple update should be relatively painless and require only a few changes.

+6
source share

Upgrade It was very simple for me: change __str__() to __unicode__() , write basic admin.py and do it. Just run the application on 1.0, test it, and when you encounter an error, use the documentation for backward-incompatible changes to find out how to fix the problem.

+3
source share

Just update the app. Switching from 0.96 to 1.0 was huge, but in terms of lagging Incompatible changes, I doubt your application even has 10% of them.

I was on the trunk before Django 1.0, so the transition for me was over time, but even then the only important things that 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 overproductions of the backend or the fact that, as someone who built the main websites, didn't even come close.

+2
source share

Just the simplest sites are easy to update.

Expect real pain if your site turns out to be for the non-ASCII part of the world (read: somewhere outside the US and UK). The most painful change in Django was switching from bytes to unicode objects inside - now you need to find all the places where you use bytestrings and change it to unicode. The worst case is rendering a template, you will never know that you forgot to change one variable until you get a UnicodeError.

Another noteworthy: the oldforms are gone, and you have no other way but to rewrite all the parts using forms (newforms).

If this is your case, and your project exceeds 2-3 applications, I would rather refuse to upgrade until it is really needed.

+1
source share

We updated the process with several steps, and I am quite pleased with this. The application in question was about 100,000 LoC and performed several basic business functions with a lot of interaction with legacy systems. We worked like this:

  • Update to django 0.97-post unicode merge. Fix all problems in Unicode.
  • Reorganize the application into reuse applications, add tests. This left us with 40,000 LoC in the main application / project.
  • Switching to django 0.97-post using auto exposure. Fix auto-escaping in reusable applications created in 3. Then fix the remaining issues with auto-escaping in mian.
  • Update to 1.0. What was left basically captured the admin stuff.

All this took about 6 months when we were working on the old production unit on our servers, moving the other branch to 1.0. In doing so, we also add functions to the production branch.

The final merge was much less messy than expected, and took about a week to merge, analyze, test, and fix 4 coders. Then we rolled out, and about a week earlier bit unexpected errors.

In general, I am quite pleased with the result. We have a much better code base for further development.

+1
source share

All Articles