Blog Migrated to Django

I've been meaning to migrate my website from Drupal to Django for a very long time. Although Drupal is an excellent content management system, I got tired of working with PHP every time I wanted to add a feature or make a change. My previous web host didn't support Python so I had to stick with PHP. Recently however, I moved the website to a VPS at Linode and decided to migrate to Django as well.

Writing a blog application in Django took very little time thanks to the reusable apps that come with Django, like syndication, comments and admin. I also had to port the blog design to Django templates and migrate the content from HTML to Markdown. I've been using Markdown at StackOverflow and I really like it. It's concise, readable and much easier to work with in a text editor than HTML. I wrote a small script to convert existing articles from the subset of HTML that I was using to Markdown.

To run the website, I'm using Apache2/mod_wsgi for the backend, and nginx as a frontend. I chose mod_wsgi because it's very flexible. As for nginx, I chose it because it integrates nicely with StaticGenerator, a Django middleware that caches pages as files on local disk. StaticGenerator has an important advantage over using Memcached with Django: cached pages are served by nginx without hitting Django at all, so it's much faster. A quick benchmark on my setup showed that it was 8 times faster. StaticGenerator can only cache full pages, but this is fine for my needs.

The blog feed now contains full articles (as opposed to short summaries). This should be more convenient to those who read the blog via the feed.

Comments

Abd Allah Diab
Abd Allah Diab's gravatar

Way to go Ayman :D

I read your book and learned how to develop Django applications. I have also published the Django Bookmarks application online. I have also developed a middle ware to get online users. I really love Django and Python.

Thank you for your book, and congratulations for the migration :)


Posted at 5:33 p.m. on April 26, 2010

anonymous Howard
anonymous Howard's gravatar
  1. Is this open source and the code available somewhere ?
  2. Why do you need two web servers for just a blog ?

Thanks


Posted at 11 a.m. on April 28, 2010

Scott Morse
Scott Morse's gravatar

I admire your blog. I am a slow learner of Ubuntu, python, and web dev. The information here is relevant. You have a gift for clear expression. You seem humble. Thus the content is inviting. Thanks for your contributions here. I live in San Marcos, Texas, U.S.A.


Posted at 8:11 p.m. on April 28, 2010

Ayman Hourieh
Ayman Hourieh's gravatar

ananymous Howard,

  1. I will share the interesting parts of the code in blog posts. I've already posted about implementing code highlighting. I'm still not sure whether releasing yet another blogging application for Django is useful. There are already several excellent ones. I wrote my own app because I had a specific set of requirements in mind and none of the available apps fit them nicely.
  2. The recommended Django configuration is to have a separate web server for serving media. In addition, StaticGenerator, which adds a significant boost to performance, integrates nicely with nginx. I could have used FastCGI with nginx, or served everything via Apache, or any of the other documented configurations. However, I'm already familiar with this setup, and it's quite common, so I decided to use it here as well.

Thanks for your comment.


Posted at 11:51 p.m. on April 28, 2010

Ayman Hourieh
Ayman Hourieh's gravatar

Scott,

I appreciate your comment. I'm glad to know that you find the content relevant. Thanks for your feedback, and I hope that you will enjoy future posts as well. :)


Posted at 11:56 p.m. on April 28, 2010

Ayman Hourieh
Ayman Hourieh's gravatar

Abd,

You've added a nice template to the bookmarking application. It looks much nicer. Your online users middleware also looks interesting. Keep up the good work!


Posted at 12:02 a.m. on April 29, 2010

Post a comment

HTML is not allowed. You can use markdown syntax to format your comment.