My Experiments with Django… with interesting results!

So I was all ready to try out this beautiful framework called “Django”. (Funny, always reminds me of the great guitarist Django Reinhardt). And so I go to the homepage of Django and get version 0.95. I decided to test it all out on my Windows box before trying it out on good ol’ unpredictable Linux (okay,okay GNU/Linux). So far so good.

Installation went off without a hitch. The prerequisites had already been loaded (Believe me, the prerequisites list is almost as big as that for GNU/Linux software packages and almost as obscure… my eternal gratitude to the maintainers of the “Cheeseshop” who make my life easier!) and I was ready to take the plunge. I decided to start with the “Django book”. In case you haven’t already got lost in the pool of URLs already (though it couldn’t possibly ever equal that of Slashdot’s), you can get this gem of a book here. Excellent book. Take my word for it!

So I start off with the initial pages and I already like these guys! The Awesome Threesome as I would like to call them – Adrian Holovaty (loved his duel with David Heinemeier Hansson in this excellent video), Simon Willison (the soft-spoken Brit) and Jacob Kaplan-Moss (the dude who presented a Django demonstration in Google). Their sense of humor (I suspect mostly Adrian’s) is wonderfully to my liking. A bit on the sarcastic-and-yet-almost-self-flagellating-and-still-almost-playing-dumb-and-yet-profoundly-enlightening-humor-which-hits-you-after-you-have-finished-laughing type. You know what I mean? Anyway, to get back to the flesh of the discussion, there I was happily following the instructions in the Django Book and configuring here, tweaking there and everything seemed to work fine. And then I try this simple example to generate a dynamic HTML page which would purportedly return the current date and time to the user and wham!!!! The whole thing throws up an ugly page full of error messages and stack messages and what not (I thought for a moment I could even see Richard Stallman’s rotund assets there). I am distraught. I am devastated. I am ruined. Naah… I am just messing around with you. In true hacker fashion, I set about dissecting the error messages, painstakingly tracing the chain of errors back to the source. Ha ha ha… who am I kidding? In even truer hacker fashion, I went straight to the source code and tinkered around a bit. I could find the source of error to be the wrong usage of the “rindex()” method on a non-string (specifically an HttpResponse object). Nothing much I could do about that so straight to the Django users’ group where I am directed very politely to an FAQ which described my problem perfectly. So the problem was with the incompatibilities between the Django Book and the Django version!

So I shake it off, download Django 0.96 and get to work all over again. And this time the damn thing won’t even install! Bwah-ha-ha-ha-ha-ha! I wipe off my tears of
half-anguish and half-amusement and set about hacking into the code again. I find that the problem lies in the setup file. The damn thing is supposed to read the directory structure in an OS independent way and yet it does not. So I take the code and change it to hardcoded directory for my specific OS (Windows XP!!!). And voila! magic! the built-in application server for Django works starts humming and gets to work and there is this beautiful HTML generated dynamically and gosh, this really is the beginning of something beautiful! Needless to say, I have raised a “ticket” with the Django folks and thanks also to robin_percy on the Django Users’ group for saving me innumerable man seconds of time on trying to hack the Django 0.95 code. For now, everything is running chummily and hopefully I’ll have only positive stuff to post about my tryst with Django hereonin!

By the by, know why I love Python? Check this out –

set(word for word in open(“words.txt”).read().lower().split())

The single line of code above will open the file “words.txt”, read all the lines in it, change them to lower case, split them into individual words and return a set of all the unique words in the whole file! Is that cool or what?!? 🙂


3 thoughts on “My Experiments with Django… with interesting results!

  1. I’m just starting out with Django, and so far I love it.

    What are your experiences with it? Did you still use it?

    Some of the things offered by Django are also available in other frameworks such as Ruby on Rails and various PHP frameworks, but personally I just much prefer Python’s syntax to Ruby’s and PHP’s.


  2. Hi Jonas,

    I had used Django for a small hobby project and this was before the 1.0 release. Even then, apart from the Python hell of dependencies in installation, I managed to use Django 0.96 without much hassle. It is a superb framework (relatively speaking) but I daresay the only reason I worked with it, and perhaps may again in the future, is because of my love for Python. 😉 … I have not used other Python frameworks but when I tried RoR, I positively despised it. The totaly bloat of directories and the condescending nature of the framework put me off totally, not to mention the Ruby language itself!
    Coming back to Django, I would like to try out the post 1.0 release and see if I still like it! One thing though – best documentation of all the frameworks.


Speak your mind!

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

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

Google photo

You are commenting using your Google 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 )

Connecting to %s