The Spectacular Blog of George Titsworth

Zilch to Private Beta Website in 10 minutes Using Django, Pinax, and Gondor

Photo courtesy of 10b travelling

In my last post, I mentioned starting a new Django project… Well, this is the process I used to go from nothing to a deployed site with user log-ins and a private beta sign-up functionality.  The total process took me a little over an hour, but after I factored out all of the time I spent researching and resolving some odd behaviors and just being dumb in general, the entire process boils down to about 10 minutes of actual work time. Not bad.

Note: I am using some processes here that are not “necessary”, but are good practices. Feel free to let me know if there are better ways to do things, or if you disagree with my process. I’m learning here and I’d love some input.

There are also some necessary prerequisites that you should have installed:

Setting up the environment

The first thing you need to do is to set up your development environment using virtualenv. Virtualenv sets up a local copy a python environment (not tied to your system installation of python). This is a great step to take so you can set your virtual environment up to match your deployment environment without having to mess with your system installation of python. For my site, Epicify, here is how I set it up:

$ virtualenv epicify-env
New python executable in epicify-env/bin/python
Installing setuptools............done.
Installing pip...............done.

$ source epicify-env/bin/activate

That was easy.

Installing Pinax

The next step is to install the Pinax infrastructure for the site. This will handle the core site elements, such as user authentication and a private beta configuration.

Once again this is an extremely simple process:

(epicify-env)$ pip install Pinax
Downloading/unpacking Pinax
  Downloading Pinax-0.9a1.tar.gz (4.7Mb): 4.7Mb downloaded
  Running egg_info for package Pinax
Installing collected packages: Pinax
  Running install for Pinax
    Installing pinax-admin script to /Users/titsworth/epicify-env/bin
Successfully installed Pinax
Cleaning up...

In the next step, I will vere off the Pinax documentation just a little bit. I do this so that I will be compatible with the Gondor site layout requirements, which expexts the root project directory to be under the repository root directory. To handle this, I just create a directory called epicify, and then create my pinax project under that directory (which creates a another directory called epicify).

(epicify-env)$ mkdir epicify
(epicify-env)$ cd epicify
(epicify-env)$ pinax-admin setup_project -b private_beta epicify
Created project epicify
Installing project requirements...
(Lots of stuff here)...

The ‘pinax-admin setup_project‘ has a few options for default site infrastructures. Use the ‘-l‘ option to see all of the options. I decided to go for the private_beta site which a basic site with an additional application that handles a limited beta functionality.

If you have any problems with this process, please see the Pinax documentation. It is pretty good about resolving the common issues.

Initializing  the git repository

It’s good practice to keep your code under some sort of source code control (and Gondor requires it). It allows you to track changes over time, back out changes that didn’t quite work as you expected, and prepare yourself for the day when your site needs more than one developer. The process is too easy not to do it:

(epicify-env)$ git init
(epicify-env)$ git add .
(epicify-env)$ git commit -m "Initial commit including pinax base"

Testing break…

Just to make sure things are working fine locally, run the following commands:

(mysite-env)$ cd epicify
(mysite-env)$ python syncdb
(mysite-env)$ python runserver

And point your browser to “”. You should have the basic Pinax site! Woohoo!! You’re in the cool crowd. If something went wrong, this is the time to drop a few F-bombs, flip over your desk, and storm off.

Or you could just debug and start back when the site works.

Deploy this thang!

Deployment preparation

At this point, we are ready to prepare our site for deployment, the process where you put it out on a public server for all of the world to see. In order to get Pinax to work with Gondor, a few special things need to be done.

First, The Pinax default installation refers to a default Pinax theme. The default Pinax theme is located under the Pinax installation directory, which is not under the project directory. To resolve this, I just copy the entire default Pinax theme directory to my my project template root.

(epicify-env)$ cp ../../epicify-env/lib/python2.6/site-packages/pinax/templates/default/ templates/

Now we need to update the file to point to the new default template location. This includes modifying the TEMPLATE_DIRS property and the STATICFILES_DIRS property. In the code, below, I just commented out the old lines that refer to PINAX_ROOT and replaced it with a similar line tat refers to the PROJECT_ROOT.

os.path.join(PROJECT_ROOT, "templates", PINAX_THEME),
os.path.join(PROJECT_ROOT, "templates"),
#os.path.join(PINAX_ROOT, "templates", PINAX_THEME),
# Additional directories which hold static files
os.path.join(PROJECT_ROOT, "media"),
os.path.join(PROJECT_ROOT, "media", PINAX_THEME),
#os.path.join(PINAX_ROOT, "media", PINAX_THEME),

The final change requires you to rename the ‘pinax.wsgi‘ file in the deploy directory to ‘

UPDATE: The real final step (forgot one) is to add the following two lines to your requirements/project.txt file:


The version of Gondor might be newer than what is available, so check the Python Package Index for the latest version.

Installing and configuring Gondor

One you have prepared your site, the actual Gondor deployment is fairly simple. This section just rehashes the instructions found on the Gondor website

To get started, install Gondor on your local system.

(epicify-env)$ pip install gondor

You then need to create a .gondor file in your home directory that contains your Gondor authentication information

username = <username>
password = <password>

Now that Gondor is installed and your authentication information is stored, it is time to create a site on the Gondor website (technically you can do this part first):

Once your site is created, you should be presented with a site key. Using this site key, you will need to initialize your project with the Gondor system. To do this, run the following command in your project’s root folder (alongside the file).

(mysite-env)$ gondor init <site_key>

This creates a .gondor directory in your project. The lat bit of project customization comes about due to the fact that Pinax runs on Django 1.2, and thus utilizes an external module to deliver static media and files (django-staticfiles). Because of this, gondor needs a configuration change to understand this requirement.

Open the .gondor/config file and change the staticfiles setting to on:

staticfiles = on

This is all the changes necessary to deploy our site, however, the  Gondor deploy command only deploys the version of your site that has been commited to the repository. So we need to make sure we commit all of our changes:

(epicify-env)$ git add .
(epicify-env)$ git commit -m "Preparations for Gondor deployment"

Finally, we just need to deploy our site to Gondor

(epicify-env)$ gondor deploy primary master
Reading configuration... [ok]
Archiving code from master... [ok]
Building tarball... [ok]
Pushing tarball to Gondor...
Deploying... [ok]

Visit: http://[deployment]

Assuming everything went smoothly, you should be able to visit the link above and voila, you have a fully functional, beta website. Sure, your branding is not there, but for 10 minutes of work, you’ve done quite a bit. Users can request an account, once given, they can log in, update their profile, etc.

We are now ready to do the actual work: adding in the domain specific behavior that makes our site special, customizing/redoing the UI, and all the other things it takes to start up a new site. But, as they say, that is another battle and another 10 minute block.

Until then!

P.S. I might have missed a step or two, so let me know if you are using this intro and run into problems. Also, I am still a relative noob to a lot of this capability, so please let me know if I’m going about something wrong or even if there is justa quicker/better way to do things. Thanks!

UPDATE: I forgot an important step at the very end… creating a superuser for your site. You’ll probably need this to log in and do things :). Once again the process is simple. Just run the gondor command to create the super user:

(epicify-env)$ gondor run primary createsuperuser

From here, just follow the instructions and you’ll be able to log right in!

More stories about , , , , , , , ,


Leave a Reply to Twitted by paltman Cancel reply

Your email address will not be published. Required fields are marked *

Zilch to Private Beta Website in 10 minutes Using Django, Pinax, and Gondor