Django

Create a new virtual environment for the project

After Python and virtualenv have been installed, a new virtual environment can be created for Django:

$ mkvirtualenv --distribute django-workshop

If virtualenvwrapper hasn’t been installed, execute the following command:

$ virtualenv --distribute .virtualenvs/django-workshop

What happens:

  • The option --distribute installs distribute instead of setuptools in the virtual environment.
  • django-workshop is the name under which the virtual environment will be available.

If virtualenvwrapper has been installed, the virtual environment is now already active.

Otherwise, it has to be activated manually:

$ cd .virtualenvs/django-workshop
$ . bin/activate

Install Django

Now we can install Django into the activated virtual environment:

$ pip install django

If virtualenvwrapper has been installed, you can list the installed packages with the following command:

$ lssitepackages -l

Without virtualenvwrapper you can check the packages in the site-packages directory:

$ ls -l .virtualenvs/django-workshop/lib/python2.6/site-packages/

There you should see a folder django.

The Django version can be checked with this command:

$ django-admin.py --version
1.4

Install timezone support

Starting with Django 1.4, support for timezones is available, which is activated by default. It is recommended to install the package pytz:

$ pip install pytz

Resources

Table Of Contents

Previous topic

Virtualenv

Next topic

Erste Schritte mit Django

This Page