Django
February 25th, 2008 | by dan |Anyone who watches the Python jobs/contracting market will have noticed by now that Django has firmly established itself as the de-facto python-powered webapp platform. Turbogears doesn’t even appear on the horizon. Not quite as bad as HD-DVD vs Blu-Ray but close.
This is a bit unfortunate for me, having written thousands of lines of code within Turbogears/CherryPy. I attribute Django’s win to a couple of thing
1. The django website and documentation are better
This is pretty important, and partly related to point 2. To find proper docs on TG you need to dive off into the websites of other projects, which are of varying quality/completeness.
2. They own all the code
This too is important. With Turbogears you get a bit of a ‘mish-mash’ feel at times. Bugs upstream occasionally don’t get fixed for months. The API (such as there is) seems to change too much between releases.
Anyway, I’m having a play with Django. My first site will be a web2.0ish effort which will first collect together all the #aber topics for as many years as can be found, then push the lot into a database and allow people to rate, tag, and comment on them. So far it’s parsing the topics out of xchat log files.
First impressions of Django:
- Documentation is great
- Template system is ugly (everyone says this)
- Database API is nice. Handier than SQLObject, but not as abstruse as SQLAlchemy
- Rule/Regex based url dispatch is ok, but I didn’t really have a problem with the CherryPy style
- The modularisation of sub-apps within a ‘website’ is cool but I’m not sure of a use yet
- The admin system seems to have little use other than in debugging or if you were writing a straight content publishing site. Nice though.
16 Responses to “Django”
By mike on Feb 26, 2008 | Reply
I should point out that Pylons is used quite frequently as well, powering websites like http://reddit.com and http://www.virgincharter.com . Not to mention zope is very widely used.
By dan on Feb 26, 2008 | Reply
I have no doubt, but I was really only on about visibility in job postings specifically - http://www.cwjobs.co.uk/JobSearch/Results.aspx?Keywords=python<xt=London%2c+South+East&Radius=5&LIds1=Cll,D,Y,BR,Bi,Bx,CS,Cs,DB,DF,DK,EL,FV,Fa,Fk,Fq,HM,HS,IR,Ic,JB,JQ,Jf,LP,MS,Mr,NR,Nf,O4,QH,Qb,Q6,Rb,Rc,R5,Sd,Sz,TI,TQ,TY,TZ,UI,UO,Q3o,Q35,Q4A,Q4B&LIds2=ZV&LIds6=Dze,B,G4,Kd,Yd,Ye,Yf,Yg,gc,gy,hZ,hc,hh
By Batiste on Feb 26, 2008 | Reply
“Template system is ugly (everyone says this)”
Could you elaborate? What would you do to improve it?
By Arnar on Feb 26, 2008 | Reply
Hi there. A couple of years ago I carefully chose TurboGears over Django. One year ago I realized I had made a mistake (by which time I already had several projects in TG).
I decided to cut my losses and just switch to Django. That was liberating to say the least. Let me address some of your points from my viewpoint:
2. Django templates _are_ ugly and limitied, but it is fairly trivial to use Genshi or Mako (or any other template system).
3. The DB api is excellent, but the integration with the Admin interface and newforms is really what makes it worth using. It is always possible to use SQLAlchemy for specific parts if they’re too complex/specialised for the django db api.
4. Same here. The regex style grows on you though. Url generation (mapping views to urls) works very nicely too.
5. This apps vs. sites was something that took me a while to apreciate. By looking at various django blogs I came to realize that Django gurus strive for application reusability and customizability. So Django apps are much more a deployment solution rather than a tool to organize your site. If you haven’t already, check out this:
http://www.playgroundblues.com/posts/2007/dec/02/django-basic-apps/
6. I don’t write straight-up publishing sites (I mostly write very domain specific webapps or information gathering tools) and the admin has proved tremendously useful. It is nice for debugging yes, but when it comes to handing over the project the admin tools means that power users and administrators can solve many problems that otherwise required a programmer and a debug session. Plus it spares you from writing configuration management stuff, admin backends, user management etc. etc.
Cheers!
ps. I still love CherryPy though
By Stephen Paulger on Feb 26, 2008 | Reply
Having developed with Pylons and Django (actually the GeoDjango branch) I have to say that I agree with you about the documentation being an important factor, Django’s docs are great.
There is also a lot of information from other websites, such as http://www.djangosnippets.org/ , which provide community advice which doesn’t seem to exist to the same degree for Pylons.
By Adam on Feb 26, 2008 | Reply
Template system is ugly (everyone says this)
You obviously haven’t used many templating languages
# The admin system seems to have little use other than in debugging or if you were writing a straight content publishing site. Nice though.
now you’re just proving you’re an idiot
By h3 on Feb 26, 2008 | Reply
“Template system is ugly (everyone says this)”
Eh, it’s funny because it’s the first thing I liked about Django and I never heard anybody complaining about it.
If you’re really not happy with it you can change it and use whatever python template system you like.
Cheers.
By John Devor on Feb 26, 2008 | Reply
> The modularisation of sub-apps within a ‘website’ is cool but I’m not sure of a use yet
The module system is very useful, indeed. It makes it _very_ easy to integrate with somebody else’s code (if properly designed).
By John Devor on Feb 26, 2008 | Reply
> I should point out that Pylons is used quite frequently as well, powering websites like http://reddit.com and http://www.virgincharter.com . Not to mention zope is very widely used.
Reddit is done with django.
By ryan on Feb 26, 2008 | Reply
I believe reddit uses web.py.
@Adam:
Re: Templating… Perhaps you are the one who hasn’t used many templating languages… The Django default templates are quite simply entirely useless. Name _any_ other templating system and you’ve got yourself a better alternative. I’m not even going to name any since literally all of them are better than the default Django stuff.
Re: “proving you’re an idiot”… Why not, instead of just trolling, give some examples of what you would use it for… I found it a pain to setup for anything but trivial models. Painful to customize and would never consider pointing a client to it to do updates to their site/content. It’s marginally better than invoking an interpreter and manually creating and editing your records.
By ryan on Feb 26, 2008 | Reply
For those curious/not in the know:
http://reddit.com/help/faq
(near the bottom)
By Beetle B. on Feb 26, 2008 | Reply
Regarding the template language, it pays to read the FAQ:
“I can’t stand your template language. Do I have to use it?
We happen to think our template engine is the best thing since chunky bacon, but we recognize that choosing a template language runs close to religion. There’s nothing about Django that requires using the template language, so if you’re attached to ZPT, Cheetah, or whatever, feel free to use those.”
On an unrelated note, as you’re using Wordpress, it would be *really* nice if you could get the plugin that allows people who leave comments to be notified of responses via email so that people like myself can carry on a conversation.
By Jonathan on Feb 26, 2008 | Reply
On Reddit:
It’s Pylons. The FAQ entry is out of date.
http://reddit.com/info/69j0t/comments/c038rlx
(spez is the technical cofounder and lead developer of Reddit).
By dan on Feb 26, 2008 | Reply
RE templates, yeah it’s pretty obvious that anything that spits out HTML can be used in place of the django template system. It works well enough, but doesn’t look nice on first glance, that’s all.
RE comment responses, Sounds good, I’ve added something which says it does that.
By Eric Elinow on Feb 26, 2008 | Reply
I just started working with django a few months ago and from scratch built http://www.inkedmagonline.com for Inked Magazine. Things were a little messy at first for some of the conventions, but I’ve quickly learned better (more django-ish) manners of executing what i wanted to do.
I think Cheetah is a nicer template engine, but I’ve found there is still enough flexibility in Django’s template system to get what I need done, done.
Eric
By Matthew Russell on Feb 27, 2008 | Reply
Having developed with Zope2+3, Pylons, Cheetah, web.py, Turbogears and django, I’d say they all have their merits for different use cases. Django is so popular right now because it sits in the middle or most use cases.
If you have a multi database setup, then django doesn’t support it within the same app (that is you need two different projects with two settings.py).
In those cases, Pylons or Zope is a better fit.
I personally can’t stand the underscore counting django database idiom, and much prefer SQLAlchemy’s approach.
It’s not that it uses underscores per say, more that it’s not intuitive (to me at least) .
It does (however much I don’t like it) however give users (as in us programmers) a consistant way to use the api, and this is what draws people to django.
SQLAlchemy has too many ways to do the same thing, and you’ve pretty much got to understand big chunks of the api before you can use it properly.
That being said, that might not be a bad thing.