Things you probably want to install to get the most out of Django
Open and run:
sudo python setup.py install
Open and run:
sudo python setup.py install
Installing Django on OS X Leopard
If you haven’t already, stick your Leopard disk in and install Xcode 3.0.
Make a home for Django:
sudo mkdir /usr/local/django
cd /usr/local/django
Get the Django trunk from Subversion:
sudo svn co http://code.djangoproject.com/svn/django/trunk/
The Django trunk should now be in /usr/local/django/trunk/, and if you ever want to check out another branch, you have a nice spot to put it next to the trunk.
I’ve you’ve previously install Python yourself, pay attention here
Find out if you’re using the right version of Python:
which python
If you don’t see:
/usr/bin/python
then delete whatever version you have sitting in your path, such as one in /usr/local/:
sudo rm /usr/local/bin/python
Once “which python” gives you “/usr/bin/python“, make sure your Python site-packages is in the right place. Running this command:
python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"
should give you:
/Library/Python/2.5/site-packages
End of previous Python caveat
Now make sure Python knows where to find Django:
ln -s /usr/local/django/trunk/django /Library/Python/2.5/site-packages/django
Put the django-admin.py script on your system path:
sudo ln -s /usr/local/django/trunk/django/bin/django-admin.py /usr/local/bin
Now you should have Django installed and ready to go. Run:
django-admin.py startproject project_name
and see.
If it works, cd into the folder it creates and try:
python manage.py runserver
Then go to localhost:8000 in your browser.
Django + MySQL:
If you want to use MySQL with Django, there’s a bit more to do. If you have MySQL ready to go, continue. Otherwise, go talk with Dan for a bit and come back here when you’re done.
Download the MySQLdb package. Stick in in /usr/local/src if you’re cool. Open it and edit site.cfg.
Change line ~ 13 from:
#mysql_config = /usr/local/bin/mysql_config
To:
mysql_config = /usr/local/mysql/bin/mysql_config
In _mysql.c:
Remove these lines (~ 37-39):
#ifndef uint
#define uint unsigned int
#endif
Go to the folder on the command line, then:
sudo python setup.py build
sudo python setup.py install
You might have to run the build command more than once. Don’t ask me why–I’m a copy and paster just like you.
That should do it. Try editing your settings.py file in your Django project and entering information for a MySQL database and see if it works.
If you experience something different than this or have any problems, please let me know directly or leave a comment.
Sources
Installing Git on OS X Leopard
It’s apparently best to install Git using both MacPorts and from source. That way you’ll get all the dependencies that are a pain in the ass to get set up, and you’ll also get the newest version of Git.
Install Git + Dependencies from MacPorts
Install the MacPorts “Leopard (Universal)” disk image from here.
If after the installation, running “which port” doesn’t show “/opt/local/bin/port“, try adding the following lines above any other path rules you have in your .bash_login file:
# MacPorts
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
export MANPATH=/opt/local/share/man:$MANPATH
# / MacPorts
Make sure MacPorts is up-to-date:
sudo port -v selfupdate
Install Git:
sudo port install git-core
Install Git from Source
Go to git.or.cz and download the newest package.
Stick the file where you want it (I prefer /usr/local/src/).
Open the file and cd into its folder. Then:
sudo make prefix=/usr/local all
(You won’t need the sudo on the last command unless you’ve got your source in /usr/local/src/, which is owned by root)
Then:
sudo make prefix=/usr/local install
If everything goes as planned, you should be able to type “which git” and see exactly this:
/usr/local/bin/git
If instead you see /opt/local/… you’re using the MacPorts version and you need to move those path rules above the other rules in your .bash_login.
Enjoy.
Bonus: TextMate Integration
To use TextMate to edit your commit messages, put the following in your ~/.bash_login:
export GIT_EDITOR="mate -w"
Install the TextMate Bundle:
mkdir -p /Library/Application\ Support/TextMate/Bundles
cd !$
git clone git://gitorious.org/git-tmbundle/mainline.git Git.tmbundle
osascript -e 'tell app "TextMate" to reload bundles'
Since Git is installed in /usr/local/bin, you’ll need to make a link to where the bundle expects it:
sudo ln -s /usr/local/bin/git /usr/bin/git
Sources:
Regular Expressions Cheat Sheet
After starting and stopping reading Mastering Regular Expressions a couple of times, I decided I needed a little refresher on the basics. So I made this:
Turning off Photoshop’s Automatic Generation of an ‘images’ Folder
File > Save for Web & Devices (cmd+shift+option+s)
On the right side of the screen, you’ll see something like this:

On the dialog that pops up, choose Saving Files

Then under Optimized Files, uncheck Put Images in Folder, or change it to something cooler like img.
