I’ve been looking at a couple of other Django tutorials lately, and recently — thanks to David, another Django learner I talked to at a Python meetup — I started making do with two great resources:

A) Youtube Series with Mike Hibbert:

B) Tango with Django by Leif Azzopardi and David Maxwell.

The Tango with Django book initially looked great, but I was disappointed to find that it doesn’t start off showing users how to run develop their app using virtualenv. (Some brief notes about using virtualenv doesn’t come until later in the book.) Mike Hibbert’s video series, on the other hand, *starts off* walking the user through installation and virtualenv.

For the sake of my own memory and to save myself some time from having to go play/pause through all 17 minutes of the installation video again, I decided to jot down the steps to creating a new Django application using virtualenv:

1) Create a virtualenv:

$ virtualenv --no-site-packages NAME-OF-VIRTUALENV

Replace all capital letters with a name of your choosing.

2) Activate your virtualenv:

$ source NAME-OF-VIRTUALENV/bin/activate

This gets you into the virtual environment. You’ll notice that your command line now has this prefix:

(NAME-OF-VIRTUALENV)Your-MacBook-Air:$

3) Change directory into your project folder and install Django:

$ cd NAME-OF-VIRTUALENV
$ easy_install django

You can also run pip install -U django==1.5.4 instead of easy_install django if you want to install a specific version of Django instead of the latest version.

4) Start a new project:

$ django-admin.py startproject YOURPROJECTNAME

You’re creating a new project.

5) Preview your project in the browser:

$ cd YOURPROJECTNAME
$ python manage.py runserver

After you type the second command, you’ll be able to preview your app in your local browser.

6) Create a new application within your Django project (think of an application as an ice crem tub inside your Django freezer — thanks for the metaphor, Two Scoops of Django!):

$ python manage.py startapp APPNAME

Update: I found another good tutorial! The founder behind Coding for Entrepreneurs Youtube series demonstrates the creation of a Django project in virtualenv on his mac:</p>

blog comments powered by Disqus
  • Hi, I'm Linda! I enjoy going to tech meetups, learning web development, and blogging about the learning path. Follow me @LPnotes

Subscribe to The Coding Diaries