django / facebook oauth

I’ve began work setting up a facebook application using django. One of the requirements is that I’m able to hook into facebook’s authentication system.

The package below seems to be the most flexible. The others that I’ve used require much more involvement and this has access directly to the api. I’m still looking for documentation on how to use the functions, but in time I’ll figure it out.

The package does require that you use python 2.5+ so I had initial trouble trying to get working with python 2.4.3, the default CentOS python package.

    The current setup is:

  • Apache2.2
  • Mod_python 3.3.1
  • Python 2.6
  • MySQL 5.0

After I make progress with the application, I’ll share my findings.

How to setup Django on Slicehost

So you’re setting a new host. This should make it easier to setup on CentOS 5.5. This list isn’t complete since you will need to setup django but this should at least get the system the basic packages to start moving.

  • vim-enhanced
  • python mod_python
  • httpd
  • mysql.x86_64
  • mysql-server.x86_64
  • subversion.x86_64
  • python
  • screen
  • mlocate
  • python-devel.x86_64
  • mysql-devel.x86_64
  • gcc
  • python-setuptools.noarch

Download  Open Source packages


tar -zxvf django.1.2.tar.gz
python install

Once installed, this should make available from command line. Installation of django typically goes into /usr/lib/python2.x/site-packages/django


You will need to have the mysql-python connector to allow django/python to connect properly to the database. This of course will require MySQL server and client is installed and running on the box.

tar -xvzf MySQL-python-1.2.3c1.tar.gz
python build
python install

Apache Configurations

There are several small steps that need to be happen before django will work properly.

Django admin files have to be made available to the public.

ln -s /var/www/html/media  /usr/lib/python2.4/site-packages/django/contrib/admin/media

Setup an eggs directory for apache

mkdir /var/www/eggs

Add the following to the httpd.conf file

<Location “/”>
SetHandler python-program
PythonPath “[‘/usr/local’, ‘/var/www’] + sys.path”
PythonHandler django.core.handlers.modpython
SetEnv PYTHON_EGG_CACHE /var/www/eggs
PythonDebug On
ErrorDocument 404 /errors/404.html

<Location “/media”>
SetHandler None

At this point, you have about 80% of the work done to get django up and running from a blank host. All that needs to happen from here is to configure your and create your django application. Good luck and hope this helps!

Python Dev Environment Setup

Now that the system is all setup, it’s time to create the development environment. I actually switched back to windows for my development environment since it was easier.

I’m on three different dev environments so its important to have consistency between the different workstations.

Eclipse Plugins

Source Code Control, in my case I’m using subversion so I’m going to use Tortise for the windows box and subversion for Mac OSX and Fedora.

Installation is simple.

Install Python
Install Eclipse, must have Java installed
Install Pydev, via ‘help > Install New Software’ and input ‘’ select PyDev and install

Windows Vista
Install Tortise SVN install and checkout the project to your local folder. – Right click and hit SVN Checkout and enter in the SVN credentials

Linux / MacOSX
svn co

Setup a project in Eclipse using python and map the folder to the dev environment
symbolically link the repo folder to your workspace folder and with a little luck things will work..

Windows Vista
mklink /D target_directory source_directory

If you’re running as a regular user you will likely have to use ‘run as administrator’ . Hit the start button, in the search box directly above the start button type in “cmd”. This will search for cmd.exe and appear in the menu. Right click and click ‘Run as Administrator’. From there you should be able to use the mklink command

Linux / Mac
ln -s target_directory source_directory

After the checkout process is done, startup Eclipse and your files should be there! If you want to create separate projects then create a separate workspace and move on.


Disclaimer: This isn’t meant to be a how-to, just some notes I jotted down when I was getting my environment setup.