How To: Install Django on OS X (Tiger 10.4)
Django is a web framework similar to Ruby on Rails, it’s crown jewel is a built in admin/CMS system that saves tons of time when setting up a dynamic site.
Django is pretty easy to install, if you have the correct version of Python, if you have MySQLdb for Python, if you know how add apps/scripts to your $PATH, if you haven’t installed a previous version, if you have Subversion installed, and especially if you’re a programmer rather than a designer who programs (I’m the latter).
“There’s two many ifs in that sentence Johnny”
~Reese Witherspoon as June Carter in ‘Walk the Line’
Let’s try and remove those IFs by going through an install step by step. Getting Django running locally the first time took me about four hours, following these instructions it should take you less than one hour. Prerequisites are that you have Apple’s Developer Tools (on the CD that came with your mac or here), MySQL (here), and Subversion (here) installed. you don’t HAVE to have subversion installed but it makes life easier.
Here we go…
- Install the latest greatest Python (2.4.3 at this date)
- Django of course needs a database so install MySQLdb (you have MySQL installed localy right?)
- Test your python installation, open up Terminal.app and type
you should see text similar to this
- Test MySQLdb. Type
(Note: >>> is the Python prompt) If the python interpreter doesn’t complain you have MySQLdb installed properly.
- Next up is Django itself. These are slightly modified instructions from the Django site. Go back to the Terminal, most likely Python is still running hit ‘control-D’ to exit. You should be in your ‘Home’ directory this is where the Django souce will be installed (it will actually just live here and links will be set up between Django and Python). Enter the following
This downloads the latest Django source through Subversion into a folder called ‘django_src’
- Create a ’symlink’ (symbolic link) so Python knows where to look for Django. This is where we part ways with the Django website’s tutorial, Python2.4 on Tiger lives in a much different directory than the one their tutorial uses (do not enter this)
our Python install’s ’site-packages’ is located at
because Python 2.4 was installed as a Framework. So our symlink looks like this
Note: [USERNAME] should be your username (wait what’s my username?! it’s your login, also shows up in the terminal on every line before the $)
- Test your django installation in the Terminal type
then
if you get no complaint from the Terminal Django is installed!
- Well…. not quite, Django uses
to start a new Django app, however django-admin.py is not on your path so Python doesn’t know where to find it. Open up .bash_profile from your root directory - if you have TextMate or BBEdit you can open it from the Terminal.
add the following line to your .bash_profile file.
Now django-admin.py is on your path, prove it by going to the terminal and echoing your path
you’ll get a response like this
Now go to the Django site and get cracking on the first tutorial.




Like this post? subscribe to the feed.






Helpful? I can’t even read it! your css is really all over the shop.
Comment by ben — September 19, 2006 @ 4:14 pm
Sorry about that dude, that post was before my CSS update. And since there’s only two posts pre-update I didn’t spend the time to change time. My apologies for the pain it may have caused you.
Comment by KreeK — September 19, 2006 @ 4:26 pm
Incredibly helpful. I just stripped out your stylesheets and voila!
Anyway, yours is the best tutorial I’ve found yet, but I’m still not up and running. This is my noobiness, not your tutorial’s fault.
I’m right with you up until the last step. Then I get:
/usr/local/bin:/Library/Frameworks/Python.framework/Versions/Current/bin:/usr/local/mysql/bin:/bin:/sbin:/usr/bin:/usr/sbin
Where yours says “2.4″ mine says “Current”. That’s the only difference I could detect. But it can’t find django-admin.py, which is totally bumming me out. Any thoughts ?
By the way, you might want to repost this with the CSS fixed. I don’t mind a bit just pulling the CSS out and reading it, but it’s SUCH a helpful tutorial, you might want more folks to see it. :)
Comment by pascal — October 18, 2006 @ 2:37 pm
KreeK, I’m a dummy. I had to quit Terminal after adjusting the bash and restart. Now it’s fine. I think. Anyway, it just ran startproject so we’ll see.
Comment by Pascal — October 18, 2006 @ 2:46 pm
Ok all cleaned up! As well as learning how to install Django on OS X we’ve found out how many requests it takes for me to fix something 2! - of course my wife already knew that :P
All it took was someone to ask nicely.
Comment by KreeK — October 18, 2006 @ 3:05 pm
After struggling for days with the many “howto install django on osx” tutorials around the web, I found this one and as promised, within the hour I’m setup! Many thanks!
Comment by Jamie — November 4, 2006 @ 11:08 am
Everything works fine until i get to
ln -s /users/[USERNAME]/django_src/django/ /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/django
I type that in to terminal then start python. i type import django and get this error
Traceback (most recent call last):
File “”, line 1, in ?
ImportError: No module named django
Please let me know what you think i could have missed.
Comment by Jason Calleiro — November 4, 2006 @ 11:27 pm
and i did replace [USERNAME] with my username
Comment by Jason Calleiro — November 4, 2006 @ 11:30 pm
The first thing I would check is which version of python you’re using, even when you install the latest python it might try to use an older install when you run ‘python’.
Comment by KreeK — November 5, 2006 @ 11:36 am
I followed the instructions on this page and everything worked up until the point of changing the bash_profile. The path specified for me would not work. Instead, I used the following:
export PATH=/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/django/bin:$PATH
This worked for me if anyone else runs into similar problems.
Comment by Kai — November 14, 2006 @ 10:58 pm
[…] Vixiom Axioms » How To: Install Django on OS X (Tiger 10.4) (tags: django python osx tutorial) […]
Pingback by Utopia Parkway » Blog Archive » links for 2007-02-01 — February 3, 2007 @ 9:11 am
Incredibly helpful. Not even 20 minutes. Thanks alot. Normally I like digging into figuring everything out when setting up a development environment but not today, and your tutorial saved the day. Thanks again.
Craig
Comment by Craig — March 31, 2007 @ 1:36 pm
This is brilliant, many thanks. I have two further suggestions:
1. The precompiled mysqldb pkg (v.1.2.1) linked ab. looks for python 2.4.x and won’t install if you’re running Python 2.5. You will either need to uninstall python 2.5, install python 2.4 alongside, or compile mysqldb 1.2.1 from scratch. If you haven’t upgraded to python 2.5, the links above work fine.
2. Kreek: you may want to un-highlight the first code sample (marked “do not enter this”) in step 6. Someone in a hurry (*mumblemumble*me*mumblemumble*) might slap that code in without reading closely. It doesn’t do any harm AFAICS but had to unlink the symlink.
Comment by Paul S — April 16, 2007 @ 7:36 pm
Hmmm…. I finished the tutorial almost entirely, up to the point of:
django-admin.py startproject PROJECTNAME
Thanks to Pascal I finally got the $PATH to be correct when using echo $PATH, but that command doesn’t work. Instead I navigated the entire path to the file, although I think you should go a little bit more in depth with this. As well as using MySQLdb 1.2.2 with Python 2.5, because I spent about an hour trying to figure out how to compile it :P Thanks for this tutorial though, without it I never could have figured any of this out.
Comment by Ian Smith — June 13, 2007 @ 10:50 pm
Thanks! Very well done.
Comment by Ben — June 29, 2007 @ 10:34 pm
[…] My blog turning one is much less exciting than everything that’s happened since I started it. A year ago being an ActionScript developer on Rails was a lonely and frustrating time (so frustrating that my first post was about installing Django). A year ago stable Rails hosting was hard to find, there was no Ruby AMF implementation, and no Flex Builder for OS X. Now you can get solid and affordable Rails hosting with Media Temple (shared) or Slicehost (VPS), two flavors of AMF for Ruby, and Apple users are no longer second class Flex citizens. […]
Pingback by Vixiom Axioms » Vixiom Axioms is a year old! — July 31, 2007 @ 6:45 pm
One things that has bitten me several times when configuring Django is making sure your system has picked up the changes to your path.
After editing your ~/.bash_profile, you should then execute the file to insure the changes are picked up with the following command:
. ~/.bash_profile
I’ve found that simply closing or opening a new terminal window isn’t enough. Anyhow, hope that helps.
Comment by Kai — October 12, 2007 @ 10:27 pm
sweeeeeet!
great tutorial…and thanks kai for your comment, i ran into the same thing changing the bash_profile…
Comment by eric — December 27, 2007 @ 12:03 am
Thanks for the tutorual, it’s the best one I’ve found, but I keep having the same problem every time i try to install Django. When i try >>> import django i get the message:
Traceback (most recent call last):
File “”, line 1, in ?
ImportError: No module named django
I’ve made sure to include my used name, and am using python 2.4.3 I’ve restarted the tutorial several time and always get the same problem.
Any help would be great.
Aaron
Comment by Aaron — June 18, 2008 @ 3:20 am
ekibastos…
ekibastos…
Trackback by \')/* — September 19, 2008 @ 5:56 pm