Setting up Django on Snowleopard

I found this tutorial to setup django on Snowleopard. Since I realized it is a little outdated I decided to document the steps I took based on it to get this up and running.

Install

As far as package managers on the Mac go, Homebrew is the new kid on the block, but in my opinion it outperforms Macports in many ways. So for all my installs I tend to use it as much as possible, if anything is not available it is easy to build it using it as well.

So for this tutorial we need the following:

  • Git
  • Mercurial
  • libjpg
  • pip
  • virtualenv
  • virtualenvwrapper

Installing all this is pretty straight forward:

brew install git
brew install pip && pip install mercurial
brew install libjpg
sudo easy_install virtualenv
sudo easy_install virtualenvwrapper

Configuration

Virtualenv changed a little since the original tutorial so setup is done by first of all creating the directory for the environments

mkdir ~/.virtualenvs

Now the directory needs to be exported and the virtualenvwrapper.sh needs to be sourced, this is done by adding

export WORKON_HOME=$HOME/.virtualenvs
source /path/to/this/file/virtualenvwrapper.sh

to .bashrc and running

. ~/.bashrc

Now let’s create an environment by running

workon
mkvirtualenv magicalenvironment
workon
workon magicalenvironment

Now you are running in the magicalenvironment.

Django and the Firstapp

Finally it is time to create a file containing some basic setup

nano django-basic-requirements.txt
# Docutils for admin documentation.
docutils
# Latest Django version
-e svn+http://code.djangoproject.com/svn/django/trunk#egg=Django

Thats it, now it’s time to setup the app using pip and switch in the environment

pip install -E testapp.com -r django-basic-requirements.txt
workon testapp.com

Time to get Django up and running

django-admin.py startproject testapp
cd testapp
python manage.py runserver

Now we can visit http://127.0.0.1:8000 an should see this

Django Testapp

Here we go a running Django development environment. Next on the agenda integrate MongoDB with Django.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s