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.

https://github.com/vikalp/django-facebook-oauth

The package does require that you use python 2.5+ so I had initial trouble trying to get facebook.py 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.

django facebook connect

Thanks to this tutorial, I was able to work in django/facebook authentication. It is minimal and works rather well. This is just the beginning of a site that I’m working on with django as the backend to a facebook app. The link below is to the original author.

http://teebes.com/blog/13/django-facebook-connect-integration-with-ajax-no-middleware

There are some basic things that will need to be done in order to make the application work the way I want to. It’s your typical run of the mill website minus the community.

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

Django

wget http://www.djangoproject.com/download/1.2/tarball/
tar -zxvf django.1.2.tar.gz
cd Django.xxx
python setup.py install

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

MySQL EGGs

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.

wget http://sourceforge.net/projects/mysql-python/files/mysql-python-test/1.2.3c1/MySQL-python-1.2.3c1.tar.gz/download
tar -xvzf MySQL-python-1.2.3c1.tar.gz
python setup.py build
python setup.py 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 DJANGO_SETTINGS_MODULE apps.settings
SetEnv PYTHON_EGG_CACHE /var/www/eggs
PythonDebug On
ErrorDocument 404 /errors/404.html
</Location>

<Location “/media”>
SetHandler None
</Location>

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 settings.py and create your django application. Good luck and hope this helps!