Skip to navigation

Installing Django on OSX

Published May 31, 2006

Whilst Django is checking out of SVN I’ll give you a quick checklist to get it up and running on OSX.

  1. Install MySQL
  2. Install darwinports
  3. $ sudo port install subversion
  4. $ sudo port install python24
  5. Add /opt/local/bin:/opt/local/sbin:/usr/local/mysql/bin to your path (before $PATH so as to use Python 2.4)
  6. Download and extract mysql-python bindings
  7. Change dir into the extracted mysql-python
  8. $ python setup.py build
  9. $ sudo python setup.py install
  10. $ mkdir ~/django
  11. $ svn co http://code.djangoproject.com/svn/django/trunk/ ~/django/django_src
  12. Add $HOME/django/django_src/django/bin to your path
  13. Add export PYTHONPATH=$PYTHONPATH:$HOME/django/django_src:$HOME/django/django_projects to your .profile

And there you have it:


$ django-admin.py
usage: django-admin.py action [options]
actions:
  adminindex [appname ...]
    Prints the admin-index template snippet for the given app name(s).
...

Instead of placing it in ~/django you could have put it somewhere nicer, like /usr/local/django, but I thought I’d keep it consistent with Jeff Croft’s article on setting up DJango on dreamhost.

Archived comments

Comments were previously allowed on articles. Though no new comments are being accepted you can see the old comments below.

  1. Allan

    Excellent, concise instructions, thought i would add a wee bit of clarity that might help:

    Step 5: If using default bash shell the actual code should be:
    echo 'PATH=/opt/local/bin:/opt/local/sbin:/usr/local/mysql/bin:$PATH' >> ~/.bash_profile
    then:
    source .bash_profile
    Step 12:
    echo 'PATH=$PATH:$HOME/django/django_src/django/bin' >> ~/.bash_profile
    then, again:
    source .bash_profile
    Step 13:
    echo 'export PYTHONPATH=$PYTHONPATH:$HOME/django/django_src:$HOME/django/django_projects' >> ~/.profile
    finally:
    source .profile

    Cheers TT!

  2. Tim Lucas

    Thanks Allan! Glad you found it useful.

    Apologies for the line breaks…

  3. Sean Schertell

    Can you please explain the difference between .profile and .bash_profile ?

    Why is some stuff going in one and other stuff in the other?

  4. Tim Lucas

    Most (all?) shells have their own preferred config file, and then fall back on .profile. If it’s BASH specific it should probably go into .bash_profile. I’m usually too lazy to pay much attention…

    Why Allan’s last step suggests using .profile beats me.

  5. Nick Muller

    That was sweet Tim!

    cheers, very much

  6. Allan

    That my newbie mistake, you’re quite right – the final step should have been consistant with the rest and read .bash_profile’ not ‘.profile’. But as Tim’s instructions indicate you can use .profile all the way through, I just put up what worked for me!

  7. baldo

    how to make this step in osx?

    Add $HOME/django/django_src/django/bin to your path

    I don’t know where is the “path” thing..

  8. Tim Lucas

    baldo: See the first comment by Allan above.

  9. Kelsey Ruger

    Just wondering. Since you are already installing Darwinports, why can’t you use that to install Django? Does it not work?

  10. D. Starr

    Screw MacPorts, just…

    sudo easy_install http://code.djangoproject.com/svn/django/trunk/

    Nothing wrong with the Python that comes in Leopard. You will need setuptools at least for this.

  11. Chris Pratt

    Also no need to install Subversion from MacPorts… comes pre-installed.

Thoughts

toolmantim

I’m Tim Lucas, a user experience developer currently in Sydney Australia.

I occasionally write, snap photos, present on various technical topics, tweet my going-ons, share teh codes and post tidbits to the scrapbook.

Most recently I published Simplifying ticket sales on sydneyoperahouse.com (February 16, 2010)

Work with me via Agency Rainford, or shoot an email to and say hello.

Powered by vegemite