My problem: I have a server running my Django apps that I set up when I had very little experience with Django, and just some more with Python. The configuraton is using Apache and mod_wsgi on Ubuntu, running on the system’s default Python installation (2.6) which has Django 1.1 installed.
I need to update my site, which has been upgraded to use Django 1.2, and would benefit from Python 2.7 (although the site itself runs on 2.6 as well, running the tests requires 2.7, since I use some of the new convenient unittest assertions from that version, e.g. assertIsNotNone
or assertIn
).
Upgrading the site will require some migrations, which are not backwards compatible (e.g. some table and field renames). Since all in all will be a delicate intervention, I’d like to create a totally separate environment for testing the revamped site while the previous version is still online. Even if it was not risky, now I know better than when I started, and it’s a good time to switch to a virtual environment setup.
Therefore, in order to proceed we will:
- Install python 2.7 with
pythonbrew
- Install
virtualenv
andvirtualenwrapper
- Create a
virtualenv
with that python version - Install all requirements with
pip
- Make a Copy of the production DB, and migrate
- Run unit tests and test using the development server
- Switch to a production setup with
mod_wsgi
, and the newvirtualenv
This article covers all steps but the mod_wsgi
setup, which will have its specific followup.
Continue reading