toolmantim

Installing Django on OSX

May 31, 2006 15:52 (Sydney Australia)

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.

Comments

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!

Tim Lucas

Thanks Allan! Glad you found it useful.

Apologies for the line breaks…

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?

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.

Nick Muller

That was sweet Tim!

cheers, very much

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!

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..

Tim Lucas

baldo: See the first comment by Allan above.

Kelsey Ruger

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

To comment on this article you must have javascript enabled.