Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Centralized Django Installations with VirtualEnv

I have a server running several different Django websites, running different versions of Django. Yesterday, Django issued security updates for 1.8 and 1.9. This means that, in order to keep everything secure, I have to go to each website and update the version of Django that it's running.

Since Django does a very good job with versioning (i.e. breaking changes happen between minor versions, like 1.8-1.9, but not between releases, like 1.9.2-1.9.4), it seems like I should be able to have a central Django installation for each minor version, 1.7, 1.8, 1.9, etc.

Is there a way to get VirtualEnv to target a specific installation so that I can have all the websites running Django 1.8 point at just one installation, and likewise for 1.9?

like image 697
tghw Avatar asked Mar 02 '16 16:03

tghw


1 Answers

One solution is to use add2virtualenv from virtualenvwrapper.

Simply, create some virtualenvs for shared django versions (of course, one virtualenv for one django major version) and on each of virtualenvs invoke command:

add2virtualenv /path/to/shared/virtualenv/lib/python3.4/site-packages

replacing path to shared virtualenv (and python version if necessary) with one that you want to use.

add2virtualenv have permanent effect, so there is no need to invoke it again after activating virtualenvwrapper.

like image 113
GwynBleidD Avatar answered Dec 07 '22 23:12

GwynBleidD