20seven

Devigner blog about development and design

Pinax Setup and Deployment

For the past four or five months I’ve been helping out and contributing to the Pinax project which is gaining popularity and buzz very quickly. If you’re not up to speed on what Pinax is, the best and most amusing way is to watch the video of James Tauber’s talk at Djangocon or simply dive in and get your social network up and running.

After the launch of Cloud27 and Djangocon, there has been much more activity surrounding Pinax and a few questions about deployment. While the documentation is being worked on, I figured I would write up some general principals on the deployment of your project.

Checkout

Obviously, you need something to work with so go get the source or using subversion…

svn checkout http://django-hotclub.googlecode.com/svn/trunk/ django-hotclub

Structure

First glance at your directory structure will reveal the following:

  • pinax/ contains a django project and templates
  • external_apps/ contains external re-usable apps brought in via svn:externals
  • local_apps/ contains re-usable apps that aren’t yet externalized
  • core_apps/ contains non re-usable apps specific to pinax site
  • external_libs/ contains external libraries

Dependencies

The only real dependency is python imaging library which is required for Photologue and its image uploader and resizing. Other dependencies that may be required for your particular server are located in the external_libs directory if you find you need them. It’s nice that you don’t have to run around google trying to find these packages, (with the exception of PIL) they are all provided for you.

Settings and Customization

Typically, the only thing you really need to change are the database connections and type depending on your preference. Create a localsettings.py file in the pinax directory and add the following (if you do not want to use the default sqlite3 setup).


# 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'ado_mssql'.
DATABASE_ENGINE = 'sqlite3'
DATABASE_NAME = 'dev.db'
DATABASE_USER = ''
DATABASE_PASSWORD = ''
DATABASE_HOST = ''
DATABASE_PORT = ''

When you have these settings set, simply run the following to create your database and install the fixtures.

python manage.py syncdb

Django-Photologue

Pinax has photo sharing capabilities and uses some of the functionality provided by . As stated in the dependencies, you will need to have PIL installed on your server to take advantage of these features.

mod_wsgi

For Apache and mod_wsgi deployments hers is a sample virtual to get you up and running.




Sample django.wsgi file:


import sys
sys.stdout = sys.stderr
import os
from os.path import abspath, dirname, join
from site import addsitedir
path = addsitedir(abspath(join(dirname(__file__), 
    'django-hotclub', 'external_libs')), set())
if path: sys.path = list(path) + sys.path

sys.path.insert(0, abspath(join(dirname(__file__), 
    'django-hotclub', 'external_apps')))
sys.path.insert(0, abspath(join(dirname(__file__), 
    'django-hotclub', 'local_apps')))
sys.path.insert(0, abspath(join(dirname(__file__), 
    'django-hotclub', 'core_apps')))
sys.path.insert(0, abspath(join(dirname(__file__), 
    'django-hotclub')))

from django.core.handlers.wsgi import WSGIHandler

os.environ['DJANGO_SETTINGS_MODULE'] = 'pinax.settings'

application = WSGIHandler()

Here is a good overview on using mod_wsgi with django if you want more information.

mod_python

For Apache and mod_python deployments here is a sample virtual setup to get you going. The following makes the assumption that you have installed the dependencies you might need.



        SetHandler python-program
        PythonHandler django.core.handlers.modpython
        SetEnv DJANGO_SETTINGS_MODULE pinax.settings
        SetEnv PYTHON_EGG_CACHE "/path/to/your/python-eggs"
        PythonPath "['/path/to/your/django-hotclub'] + sys.path"
    
    Alias /media/ /src/django-trunk/django/contrib/admin/media/
    
        SetHandler none
    
    Alias /site_media/ /path/to/your/django-hotclub/pinax/site_media/
    
        SetHandler none
    


Additional Resources

If you have any additional question or need help, the quickest way to get it is to join us in the #pinax irc channel on freenode.

[UPDATE] Eric Holscher has also posted a nice Getting Started Guide worth checking out.