blog stats
seamusc.com

How to get Django working on digiweb.ie using django.cgi

Published on June 11, 2007

I just thought I'd post exactly what I did to get django running on digiweb.ie shared hosting

First I downloaded and extracted Django version 0.96 to ~/Django-0.96

All requests will then be forwarded through the django.cgi script which I have saved as cgi-bin/dj

.htaccess

RewriteEngine on
RewriteRule ^cgi-bin/ - [L]
RewriteRule ^media/ - [L]
RewriteRule ^(.*)(/)$ cgi-bin/dj/$1/
RewriteRule ^$ cgi-bin/dj/home/
Read More

Django Wiki Part 2

Published on May 31, 2007

Building on the simple wikitags parser I wrote about earlier I'm now trying to build an application around that template tag.

A basic wiki should the following features:

  • Give the user the ability to create and edit pages.
  • Recent versions of a page should be stored to help see what has been changed and to mitigate the effects of spam.
  • The syntax of the markup/formatting language should be simple and allow easy linking, especially internal linking.
  • Have the ability to contain static pages

The django.views.generic.create_update module looks like the obvious choice to use for creating/editing pages but the basic structure will be something like this.

Read More

Break page template tag

Published on May 31, 2007

Just looking over some of the posts here I realised that many of them are very long. Django's template system will let you truncate a piece of text using the truncatewords:N tag but this often is not what you want.

For this site if i decide to truncate all my posts at say 200 words then it is possible that a <code> or <p> tag will be left open, which will mess up the appearance of the page.

It would be nicer if I could just tell the template system where to break my post so that bad things don't happen or that a post is broken with only a few words to go.

This little piece of code should implement this, breaking the page when it finds BREAKHERE on it's own on a line.

Read More

RSS feeds in Django

Published on May 22, 2007

Adding RSS feeds to your site is another thing that django makes so easy for you. To start off add

(r'^feeds/(?P<url>.*)/$', 'django.contrib.syndication.views.feed',
    {'feed_dict': feeds}),

to your urls.py file

Read More

Django Flowchart

Published on May 21, 2007

Just found this and need to stick it somewhere so I don't lose it.

Read More

Comments

Published on May 19, 2007

Django really is a wonderful piece of software. After watching a video of Jacob Kaplan-Moss' presentation at google where he mentioned that users can comment on almost all content on LJWorld.com I thought "hey that's a pretty cool idea, I want to do that too". So I did, but the really cool thing is just how easy it was to do.

First add 'django.contrib.comments', to your INSTALLED_APPS in settings.py

If your using a custom view instead of django's generic views then you'll need to add

from django.contrib.comments.models import FreeComment

to your views.py

At the top of the template where you want to display the comments add this in

{% load comments.comments %}
Read More

Django Wiki

Published on May 19, 2007

Update: I have expanded on this some more here

Update: Fixed a number of issues, should now be working

Update: I have noticed a lot of people coming here after searching google for "django wiki". If you decide to use this code as a basis of your own template tag please let me know just so I know if it actually works reliably.

I've started designing a wiki for django as I can't seem to find one that exists already. It shouldn't be all that hard to do. I've started by just creating some simple search and replace statements using python's regex module re

Read More

Django on digiweb.ie

Published on May 18, 2007

I finally got this site up and running on digiweb.ie's free student hosting package. The site is powered fully by django

The Web framework for perfectionists with deadlines

As digiweb do not support mod_python or fastcgi on this package I ended up having to use django.cgi to process requests. This method is described as being very slow as for each request an instance of python plus all of django's code needs to started and loaded into memory but I really haven't noticed a delay. Kudos to digiweb.ie for their very generous hosting package!

Read More