A blog app in Django

As I said in the previous post, this blog is not using Wordpress. In fact, it's not using any commonly available blog application. Instead, I wrote my own blog app for it in Django. Yes, it is generally a stupid idea to rework the wheel when there are other more capable apps with fewer bugs out there, but I did have a couple of good reasons:

  • I have very little experience in web development. I have some upcoming projects planned, but I'd really rather get my feet wet in something less critical. A simple blog application seemed perfect.
  • I've had my eye on Django for some time and wanted to try it out, but never had a good reason to do so. This seemed like a good reason.
  • I was tired of having to upgrade Wordpress constantly.

My opinion of Django so far

I chose to use Django because I've come to like a lot of the ideas behind Rails, but I just can't seem to become a fan of ruby. Perhaps I've been using python for too long, but ruby just doesn't feel right to me. Django seems to be the leading competitor to Rails, and uses python, so it seemed like a great choice.

So far, I very much like Django. It seems to be a very well designed framework and makes many things easy without making anything impossible. The model layer abstracts database access very well, and URLConf makes laying out where things are very easy. Deploying apps, while not as easy as a php app, is not bad at all with mod_wsgi. There are a couple of things I'm not a fan of, but I can certainly live with them. For instance, I wish I could put python code in templates the way you can put ruby code into Rails templates. I get that this was done intentionally to ensure that I don't break MVC separation (which it did ensure as I was developing this blog), but sometimes I'd prefer to have a little more rope to hang myself with.

That said, I've very much enjoyed using Django and look forward to continuing to use it in the future. It's integration with Google's App Engine is especially appealing, so hopefully it will become a more comfortable tool in my tool belt soon.

Practical tips

For anyone getting started with Django, here are a few practical tips that I discovered during this project:

  • Django, CentOS 5, and MySQL don't play nicely together by default. CentOS includes MySQL-python 1.2.1, which is too old to use with current versions of Django (I'm using 1.1.1). I could have tried to build a newer version of MySQL-python (though I'd need to make sure it would work with the python 2.4 that comes with CentOS 5), but instead I just switched to using PostgreSQL, which I already had set up and works just fine. Since the model layer abstracts the database so well, I just had to change a couple of lines in the settings file to switch to PostgreSQL.
  • The Big Nerd Ranch has some very nice Coda modes for Django. I've specifically liked the template mode.
  • If you use the django.contrib.syndication app to create RSS feeds (which works quite well), make sure you change the name of the default site in the Sites app. By default, it will be example.com, and this will be used in your RSS feed links if you don't change it to the appropriate domain name.

It took me about a day (spread over a 3 day weekend) to write this blog app, and I'm pleased with the results. I'm sure I'll keep hacking on it for some time, but Django will hopefully make that pretty easy.

Comments

There are no comments yet

Add a comment