One of the projects I’ll be involved in at the start of my new post-doc is developing a website. This site will be a portal to enable researchers in our field to communicate, as well as a gateway to the database I will (likely) be developing.
I’ve tinkered with Django before and really liked it. I’ve recently heard about Pinax, which is an open-source set of Django applications that are designed for general “plug and play”-like use on a variety of websites. Many of the features of Pinax are elements that would be great to implement on this portal site I need to work on.
I’ve heard quite a bit about how fast it is to develop sites using these methods, so I’ve decided to take 4 hours out of my Saturday and put this to the test. Of course I’m a super-green programmer, so it’s a tough test indeed. I’ll be updating this post as I go with progress reports, so stay tuned!
10:30-10:45 AM – Setting up the environment
I’m working on two machines today. My linux box is where the actual Django/Pinax will live, and I’m using a Windows machine to update the blog and do graphics work (I’m still a slave to Photoshop).
I’ve already got a recent SVN version of Django installed, so the first real step is installing Pinax. First let’s download the SVN version:
svn checkout http://svn.pinaxproject.com/pinax/trunk/ pinax
The installation docs for Pinax include some simple instructions for obtaining dependencies. Following the instructions verbatim gives you both a recent copy of Django as well as Pinax itself, so you can probable just start from there if you are new to the system.
You can then use a couple of methods to install the various dependencies. Since I’m doing this the quick way, I just ran:
pip install --requirement src/pinax/requirements/external_apps.txt
Which should install everything. This cranked away in the terminal for a bit.
After it finished, I changed into the src/pinax/pinax/projects/complete_project/ directory and ran:
./manage.py syncdb
and
./manage.py runserver
and here is what we see:

Vanilla pinax installation
Not bad at all for 15 minutes of work. Next up: investigating the Pinax back end and customization.
10:45 – 11:15: Exploration
During the installation process, I was asked to create a super user. These credentials can be used to log in to the vanilla pinax site. On the login screen, we already see one of the features of pinax – integration with OpenID:

pinax login screen
Once logged in, you are directed to a page which gives you some user functions. What I want to see first however is the admin area, which is available as a link at the top right of the screen. This is just the baked-in admin that Django itself includes (which is really great, don’t get me wrong). You can click on the various modules to change them, add new items, etc. To be honest, this isn’t as exciting as I thought it might be; let’s go back to the user page.
Just exploring the tabs along the top, it’s very simple to edit your user profile, create projects, etc.

Twitter clone in Pinax
I did run into a few bugs here. When trying to add a bookmark, I got an error which broke the page, giving a template syntax error:
Caught an exception while rendering: 'NoneType' object has no attribute 'append'
The “Locations” tab also coughed up an error, but this is simply because I hadn’t entered an API key for Yahoo maps yet.
When trying to add events to a tribe’s calendar, it initially didn’t work at all. I had to first enter an event in the admin screen to get the calendar link on the user side to work at all. Once this was in place, trying to add an event was difficult because the date/time fields were just unguided text entry that would give an error stating “Enter a valid date/time.” whenever I would try to put in the information.
Looks like we will have to do some troubleshooting.
11:15 – 11:45: Moving out of the nest
Before we get into this, however, let’s get ourselves into a better position from which to work from.
I copied the pinax “basic project” folder out into a new directory. I edited the settings.py file to point at the Pinax installation, but got an import error when trying to view this new project:
ImportError at /
No module named basic_project.urls
Next I tried going into my pinax bin directory and using the following command:
python pinax-clone-project.py ../projects/basic_project /home/user/path/to/myproject/
I then changed into the new directory and edited the settings.py file (line 83) to read:
ROOT_URLCONF = 'myproject.urls'
This worked, and I could now log in to the basic site. Next I’ll re-enable some of the apps.
Hour 1 is done
11:45 – 12:30: Enabling applications and customizing the template
Since I cloned the basic project, I want to turn back on some of the applications. I opened up the settings.py files for the “complete project” included with Pinax and that for my project, and pasted in the applications I wanted under INSTALLED_APPS. I also had to copy some code over into TEMPLATE_LOADERS, MIDDLEWARE_CLASSES, TEMPLATE_CONTEXT_PROCESSORS and COMBINED_INBOX_COUNT_SOURCES. In the end the changes were so extensive that I just gave in and copied over the entire text of the complete_project settings.py file and commented out the stuff I didn’t want.
Unfortunately, when I would try to run syncdb, I’d get an error:
Error: No module named photos
which I couldn’t trace back by commenting out certain lines, etc. At this point I’m starting to get a hair frustrated.
Back to square one. I deleted that project and just cloned over the complete project as described above, and we were back in business.
Now let’s try to get rid of the applications I don’t want: swaps and locations. I had already commented these out under INSTALLED_APPS in settings.py, but they still show up in the template. This should be an easy fix… let’s just open up site_base.html in the templates directory and delete the code for these tabs.
We don’t even have to restart the development server for this one; just refresh the page and they are gone!
That took much longer than I had hoped… I need a short break.
12:30 – 2:30: Theming and visual customization
Rather than break this out into small chunks, I’m just going to lump the second half under theming and customization. Obviously I don’t want the vanilla look complete with Pinax logo at the top, so let’s dive into the Django templating system.
Firstly, I made a directory in the myproject folder called site_media, and placed a custom logo in a subfolder of this called images. To display this image, I just had to modify site_base.html under the templates directory to read:
{% block logo_link_image %}<a href="{% url home %}"><img src="{{ MEDIA_URL }}/images/logo.png" alt="" /></a>{% endblock %}
I also had to change a little bit of myproject/media/base.css in order to avoid resizing the new logo.
Most of the rest of my time was spent playing around with the base.css file, just getting a feel for what defined the different bits of the site. I think I got a little burnt out on some of the minor bugs, and just didn’t have the drive to get my hands dirty mucking about at the lower levels any more today.
That isn’t to say that I’m not very impressed with Pinax. I haven’t even mentioned some of the nice features (like built-in RSS feeds for the twitter clone). There are some things that I’d like to see added, like auto-population of slug fields, however I plan on working some more with this system over the coming weeks to see if I can’t iron out some of the kinks & problems. I’m just a bit of a slow learner, so it’s going to take me longer than this afternoon to sort out exactly what changes need to be made and where to make them.
Recent Comments