Background Image
Table of Contents Table of Contents
Previous Page  172 / 478 Next Page
Information
Show Menu
Previous Page 172 / 478 Next Page
Page Background

$

git add requirements.txt

$

git commit -m"Add requirements.txt for virtualenv"

While Django 1.7 isn’t quite out yet, you can use

pip install

https://github.com/django/django/archive/stable/1.7.x.zip

,

and just add the URL instead of the "

Django==1.7

" to

require‐

ments.txt

; pip is magic enough to figure that out. Test it by doing a

pip install -r requirements.txt

locally, and you should see pip

concluding everything is already installed.

And now we do a

git push

to send our updates up to our code-sharing site:

$

git push

And we can pull those changes down to the server, create a virtualenv on the server, and

use

requirements.txt

along with

pip install -r

to make the server virtualenv just like

our local one:

elspeth@server

:$

git pull

# may ask you to do some git config first

elspeth@server

:$

virtualenv --python=python3 ../virtualenv/

elspeth@server

:$

../virtualenv/bin/pip install -r requirements.txt

Downloading/unpacking Django==1.7 (from -r requirements.txt (line 1))

[...]

Successfully installed Django

Cleaning up...

elspeth@server

:$

../virtualenv/bin/python3 manage.py runserver

Validating models...

0 errors found

[...]

That looks like it’s running happily. We can Ctrl-C it for now.

Notice you don’t have to use the

activate

to use the virtualenv. Directly specifying the

path to the virtualenv copies of

python

or

pip

works too. We’ll use the direct paths on

the server.

Most people like to create a virtualenv for a project as soon as they

start it. I only waited until now because I wanted to keep the first few

chapters as simple as possible.

Simple Nginx Configuration

Next we create an Nginx config file to tell it to send requests for our staging site along

to Django. A minimal config looks like this:

144

|

Chapter 8: Testing Deployment Using a Staging Site