Getting Started§

Your Development Environment§

The Environment

Three important factors for your environment:

  • Isolation
  • Determinism
  • Similarity

Isolation§

Determinism§

Similarity§

Setting Up Your Environment§

Create a Clean Workspace§

$ mkdir tutorial
$ virtualenv ./tutorial/
New python executable in ./tutorial/bin/python
Installing setuptools............done.
Installing pip...............done.
$ source ./tutorial/bin/activate
(tutorial)$

Start a Requirements File§

Create a requirements.txt in the tutorial directory with a single requirement in it.

Django==1.5.1

Installing Requirements§

And then we can use pip to install the dependencies.

(tutorial)$ pip install -U -r requirements.txt

Downloading/unpacking Django==1.5.1
  Downloading Django-1.5.1.tar.gz (8.0MB): 8.0MB downloaded
  Running setup.py egg_info for package Django

    warning: no previously-included files matching '__pycache__' found under directory '*'
    warning: no previously-included files matching '*.py[co]' found under directory '*'
Installing collected packages: Django
  Running setup.py install for Django
    changing mode of build/scripts-2.7/django-admin.py from 644 to 755

    warning: no previously-included files matching '__pycache__' found under directory '*'
    warning: no previously-included files matching '*.py[co]' found under directory '*'
    changing mode of /home/nathan/p/edt/bin/django-admin.py to 755
Successfully installed Django
Cleaning up...

Beginning a Django Project§

Scaffolding

Creating the Project§

(tutorial)$ django-admin.py startproject addressbook .
manage.py
./addressbook
    __init__.py
    settings.py
    urls.py
    wsgi.py

Project Scaffolding§

manage.py
Wrapper around django-admin.py that operates on your project. You can run the tests or the development server using this.
settings.py
Your project configuration.
urls.py
URL definitions for your project
wsgi.py
A wrapper for running your project in a WSGI server.

Creating the "App"§

(tutorial)$ python ./manage.py startapp contacts
./addressbook
./contacts
    __init__.py
    models.py
    tests.py
    views.py

Review