logo sudovi.com
- X /home/ryan/Django First Impressions -- May 30, 2008 9:31am

Recently a colleague of mine rewrote one of our clients' site in Django/Python. I'm his backup and so I'm taking some time to learn Django/Python and trying to get familiar with it.

I took the tutorial over at djangoproject.com and while I think its going to take alot of getting used to on my part, I did enjoy the little walkthrough.

The Setup: Projects in Django is setup a bit different than anything I've done before. You start a project, say some website and then that project is made up of a bunch of mini-apps. You tell that project which apps to use by editing an INSTALLED_APPS field in a settings.py file that gets created when you start your project. For an MVC-type architecture (more on *that* later), it doesn't setup its directory structure in anyway that is familiar to the other three major MVCs I've worked with (Grails, Code Igniter, Rails). Again, more on that later.

The Good: Django gives you a wicked cool admin interface right out of the box with built in authentication. I didn't have to write a single stitch of code for this. Just edit a settings.py file and tell it to use the admin app and you're all set. It makes adding searchable fields and sorting a breeze and the interface itself if heads and tails above rails, and perhaps only slightly better than Grails.

The Bad: Those Python folks just gotta be different. Different is okay, but the rest of the world is calling things like this Model, View, Controller and the Django folks are referring to it as Model, Template, View. So right off the bat for me, the terminology was messing me up. In Django, Views are actually the Controller functions, and Templates would be the HTML files using Django's templating language. I found that confusing. Along with that there is an overwhelming use of underscores...they're everywhere man. Method names, used as separators when chaining some of the dynamic sql filter methods, etc. Not at all easy on the eyes.

Aside from that, I did find myself a few times saying to myself: "Wow, thats kinda cool" but it really didn't show me a whole lot that I couldn't get from the other language/framework combinations I've been exposed to. I think I'm going to like it better than Rails, but not sure it will replace Grails or PHP/CI for me. That doesn't mean I won't use it, (I have to for my job) but it won't be my first choice at the moment. Perhaps the more I work with it, the more enthused I will become. I'm still waiting for that "AH-HA" moment that I got with PHP/CI or Grails and I haven't gotten it yet.

The tutorial takes you through writing views and templates--(controllers and views)--the hard way first and then shows you what they call generic views. By using some regex foo and method calls in the urls.py file, you basically tell Django to give you some default list and show code for your objects. For me this felt really backwards as I'm used to the whole scaffolding idea to produce this effect.

URL routing are all handled by urls.py which is collection of regular expressions that requests get run against and then forwarded to the appropriate place depending on which regex the request matched. Its very powerful, but certainly you will need to brush up on your regex. There doesn't seem to be a lot of convention over configuration here outside the database level and seems to rely more on "if you do this alot, import this shortcut" which works, but as I stated earlier, its going to take some getting used to.

I did like the fact that the templates--(views)--are kept outside of directory structure for the project. It really separates things out and is a way to keep it organized.

In closing, I am truly looking forward to learning more about Django/Python (and really Python itself) and perhaps using it on some projects here and there. The problems that I have with it are really things that I can overcome. In the end, I'm bound to learn alot from picking it up. Its a good framework, but I'm not sold yet. If anything, its another tool in my belt.


~
:wq!


- X /home/Freddy Daoud -- 2008-05-30 21:23:09
Thanks for sharing your experience. Your writing style and attitude are very pleasant, and I enjoy reading about your impressions.

Cheers,
Freddy

~
:wq!


- X /home/ryan -- 2008-05-30 22:36:37
@Freddy -- Hey man, thanks for the kind words...hope to see you come back again soon.
~
:wq!


- X /home/Jonathan -- 2008-05-30 22:52:23
@ryan -- Agreed - Enjoyable reading experience !! :)

@Freddy -- This article is Godsent - I have just started getting into Python with Django and you have really echoed my thoughts.

Let's see how I like it. I gotta say, Google AppEngine is really forcing it upon me :)
~
:wq!


- X /home/Kjartan -- 2008-07-20 22:34:30
Very good article. Like speaking out of my mind. I cant really see what exactly it is that makes Djano so much better than the others.
~
:wq!


- X Add Comments
All Fields Req'd (I won't display your email)

Bold: [b]your bold text[/b]
Italics: [i]your italic text[/i]
Underline: [u]your underlined text[/u]
Link: [mylink]http://wherever[/mylink]

Copyright 2008 -- all rights reserved