Fernando Correia’s Weblog

October 22, 2008

Exploring Pinax – Part 1

Filed under: Software Development — Fernando Correia @ 8:13 pm
Tags: ,

What this is about

After learning how to build a Flex client and a Python server running on Google App Engine, I decided to try a pure-Web, pure-Python alternative. I chose Django, a first-class Web framework. I went through the tutorial and read the excellent book Practical Django Projects. The next step is building a website with some applications.

Fortunately, I found out about the Pinax project. It builds a website framework over Django and provides patterns for interoperable applications. I decided to learn how to leverage it so I can learn best practices and use some of its nice features like notifications.

I will do my learning in the open, as I did before, sharing my path and my discoveries. This is a journey from the eyes of a n00b that knows very little about Python, Django and Pinax.

I found out that this process helps me focus and structure my self-learning. I hope it may be useful to someone that follows the same path. And maybe someone more knowledgeable will correct one or two of the bloopers I make.

Installing Pinax

I started in a development environment that was already configured to run Django applications and had its fair share of tools, like a Subversion client and sendmail. You will have to refer to basic Django and Python material if you need to learn how to get to this point. Also, all my work is being done on Ubuntu 8.10, so you may need to adjust some commands if you use other environment.

Making a directory for Pinax:

$ mkdir ~/opt/django -p
$ cd ~/opt/django

Downloading Pinax and associated applications and libraries:

$ svn checkout http://svn.pinaxproject.com/pinax/trunk/ pinax

I am using version 0.5.0rc1. Things might be different if you use a newer version.

Creating a sample project

Edit: I changed these instructions twice, first to reflect best practices, thanks to a tip by Bob Haugen and later when Pinax was updated to require only changes in settings.py and not in manage.py.

Pinax comes with a sample project that can be used directly, but I will create an independent clone that I can change at will without getting in trouble with repository updates later.

$ cd pinax/projects/
$ svn export complete_project/ ~/Projects/exploring_pinax

Now we must edit settings.py to reflect the directory where we installed Pinax:

$ cd ~/Projects/exploring_pinax
$ vi settings.py

Change PINAX_ROOT to the main Pinax directory. For instance:

...
PINAX_ROOT = '/home/fernando/opt/django/pinax'
...

Also set ROOT_URLCONF using the name of the directory you exported the website project to:

...
ROOT_URLCONF = 'exploring_pinax.urls'
...

After that, save settings.py.

If we want, we can also create a file for future local settings like database passwords. I won’t use it now, but it may be handy to have it already created:

$ touch local_settings.py

Now create the local sqlite3 database:

$ python manage.py syncdb

When asked, create a superuser (admin).

Starting the website

$ python manage.py runserver

Open http://127.0.0.1:8000/ in your browser. You should have a Pinax website running. Congratulations! Login with your superuser and explore at leisure.

If you want to follow this series, browse http://fernandoacorreia.wordpress.com/tag/pinax/ for more articles or subscribe to my feed.

Your feedback is most welcome.

About these ads

11 Comments »

  1. Should
    “$ cd myproject/
    $ vi local_settings.py”

    be

    $ cd myproject/
    $ vi settings.py
    ?

    or does vi create a file by that name if it doesn’t exist?

    Comment by Lee Hinde — October 22, 2008 @ 9:06 pm

  2. Lee: Yes, the idea is to create a new file named “local_settings.py”. At least on my system (VIM 7.1) that command does this. Feel free to use any other editor, of course.

    Comment by fernandoacorreia — October 23, 2008 @ 7:02 am

  3. [...] the first part I got the sample website running. Now I’m going to add a section for a new [...]

    Pingback by Exploring Pinax - Part 2 « Fernando Correia’s Weblog — October 23, 2008 @ 7:59 pm

  4. [...] website inside Pinax’s project directory. There was no real harm, but he was right. I updated my instructions so Pinax and the custom website are in separate [...]

    Pingback by Exploring Pinax - Part 6 « Fernando Correia’s Weblog — October 30, 2008 @ 7:53 pm

  5. [...] Part 1: Installing Pinax. [...]

    Pingback by Exploring Pinax Series « Fernando Correia’s Weblog — November 8, 2008 @ 8:26 am

  6. Hi,
    I’m trying to follow your tutorial but something goes wrong:

    marco@arrakis:~/Projects/exploring_pinax$ ls
    apps deploy __init__.py locale manage.py media settings.py templates tests urls.py
    marco@arrakis:~/Projects/exploring_pinax$ python manage.py syncdb
    Error: Can’t find the file ‘settings.py’ in the directory containing ‘manage.py’. It appears you’ve customized things.
    You’ll have to run django-admin.py, passing it your settings module.
    (If the file settings.py does indeed exist, it’s causing an ImportError somehow.)

    Any tip on what I’m missing?

    Comment by Marco Carvalho — March 19, 2009 @ 12:47 pm

  7. @6 I have the same prob. No Fix yet …

    Comment by Neppo — April 5, 2009 @ 3:26 am

  8. hello, thanks much for those articles.
    Even if they repeat parts of django tutorial, they are really valuable.

    I was recently struggling with ajax form validation under pinax, that could be a good next one to write :)

    Comment by David Pravec — April 10, 2009 @ 10:13 am

  9. When i try host pinax complete project in apache server using mod python. I got the exception IO Error

    Comment by Aju — July 3, 2009 @ 6:49 am

  10. @6 + @7 – did you find a solution to this…? I’m also experiencing this error…

    N

    Comment by Nat — August 17, 2009 @ 10:05 am

  11. Hi there, thanks for the article. I’m having the same problem as described by comments #6,7 & 10, thanks.

    Comment by Dave — September 5, 2009 @ 5:16 am


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

The Rubric Theme Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: