Using virtualenv with legacy Django projects

Finally, I'm going to start using virtualenv for my Django projects on my development machine. Before starting, I want to know if there are any special considerations for working with my existing projects. My supposed workflow looks something like this:

  • create new virtualenv
  • activate new virtualenv
  • Install Django There
  • pip install all the packages that I know I need for my existing project
  • copy the Django project files, application files and git files to the project folder in virtualenv.

Edit 6. create deployment requirements file

This is obviously very simplified, but are there any steps or considerations that I fundamentally lack? Can git be happy in moving? Is it also best to have a separate virtualenv for each Django project?

I know this is not a typical code problem, but I hope that those who know more than me can point me in the right direction.

Many thanks.

+8
django pip virtualenv
source share
1 answer

I don’t see a big problem when transferring your projects, and I think that your five-stage plan is correct, in particular, for steps 3/4/5 (I would combine them), you can handle project dependencies with pip, possibly using requirements files .

Requirement files are text files that tell packages to be installed on your virtual server, including your git projects, which can ultimately be deployed in your virtual environment as development eggs (they bring version control information with them). When you have a req file, this is the question:

pip install -r file.req 

so that all necessary packages are installed in your env. As you can see from virtualenv docs, a typical req file will contain something like:

 django==1.3.0 -e git://git.myproject.org/MyProject.git#egg=MyProject 

I usually save each project in my own virtualenv, so I can deploy it to the production server in the same way as for local development.

+6
source share

All Articles