Installation and configuration

Fandjango is best installed with pip:

$ pip install fandjango

Configuration

In your ``settings`` module...

  • Add fandjango to INSTALLED_APPS

  • Add fandjango.middleware.FacebookMiddleware to MIDDLEWARE_CLASSES

  • Add url(r'^fandjango/', include('fandjango.urls')) to your patterns.

  • Specify your Facebook application’s id, secret key and namespace:

    FACEBOOK_APPLICATION_ID = '...'
    FACEBOOK_APPLICATION_SECRET_KEY = '...'
    FACEBOOK_APPLICATION_NAMESPACE = '...'
    

Note

If you’re using Django’s CSRF protection middleware, you need to make sure Fandjango’s middleware precedes it. Otherwise, Facebook’s requests to your application will qualify as cross-site request forgeries.

Finally, synchronize your database:

$ python manage.py syncdb

Note

If you’re using South, run schema migrations instead.

Mobile/Web Middleware

fandjango.middleware.FacebookWebMiddleware
Add beneath fandjango.middleware.FacebookMiddleware to support Facebook mobile apps and web based Facebook login.

Optional settings

FACEBOOK_APPLICATION_CANVAS_URL
A string describing the Facebook application’s canvas URL.
FANDJANGO_DISABLED_PATHS
A list of regular expressions describing paths on which Fandjango should be disabled.
FANDJANGO_ENABLED_PATHS
A list of regular expressions describing paths on which Fandjango should be enabled.
AUTHORIZATION_DENIED_VIEW
A string describing a view that will be rendered for users that refuse to authorize the application.
FACEBOOK_APPLICATION_INITIAL_PERMISSIONS
A list of strings describing permissions that will be requested upon authorizing the application.
FANDJANGO_SITE_URL
Only applicable when using fandjango.middleware.FacebookWebMiddleware. Determines where to redirect user post authentication. If not set, Fandjango will attempt to construct the redirect URL automatically.

Dependencies

In order to install and use Fandjango, you will need five primary pieces of software:

Development dependencies

If you are interested in contributing to Fandjango, you will also need to install some or all of the following packages:

For an up-to-date list of exact testing/development requirements, including version numbers, please see the DEPENDENCIES file included with the source distribution. This file is intended to be used with pip, e.g. pip install -r DEPENDENCIES.

Upgrading

You may have to change your database schema when you upgrade Fandjango. Thankfully, Fandjango bundles South migrations and so upgrading your database is as simple as running python manage.py migrate fandjango.

If you’re not using South, you’re on your own.

Source code checkouts

To follow Fandjango’s development via Git instead of downloading official releases, please see our Github mirror.