Faris
Faris

Reputation: 50

Running Two Django Apps Under Different Versions of Django

I inherited a situation where we have a number of apps under a single Django project. The apps are mostly unrelated, but are still in the same project.

The project is using Django 1.6.4 and we want to upgrade to at least 1.8 to get on a LTS version. I would like to do this in a controlled, incremental manner - upgrading each app, one at a time.

Is it possible to run two separate apps under two separate versions of Django, both in the same Django project. Or, is our only option to break each app out into its own project, one at a time?

Upvotes: 2

Views: 481

Answers (1)

grochmal
grochmal

Reputation: 3027

You can't (or better, you shouldn't), only a single version of django can safely read settings.py with even slightly related apps. If you allow two separate versions of django to read and execute a single settings.py chaos will likely arise.

In theory you can add an extra settings.py file, comment out certain apps (given that there are no dependencies), and boot a second django instance on the same database. But that is asking for problems.

For example, if a specific model.*Field is implemented slightly differently between the django versions you will run into database inconsistencies. It is probably a lot safer to upgrade all apps at once than have two versions of django reading/writing from the same database table.

In other words, if you are 100% sure that you can create two settings.py files one with apps A and another with apps B in INSTALLED_APPS and not a single app will appear in both settings.py, then you're safe. I have yet to see a django project that dependencies between apps would allow to separate it in two sets of apps cleanly, but, if you can manage that in your project, you can safely start two instances of django (each with a different version) passing the correct setting.py to each.

Basically:

The apps are mostly unrelated

The word "mostly" in there is what kills it.


On the other hand, you always have the option of making a copy of the database and making two django projects, each connected to one database instance.

You can then freely test the new version of django on a database that you will throw away later. It is a much safer option for upgrades.

Upvotes: 2

Related Questions