8 Reasons Why You Should Try Django
January 6, 2010

I have been using Python for quite a few years, but mostly for writing one off sysadmin scripts, command line utilities, and of course PyRadio. Most of my web development work has been done with PHP. The language gets a lot of bad press, some deserved and some not so much. I’ve had my own gripes, but all-in-all I’ve been fairly happy with PHP.
Several months ago, though, I thought I’d give Django a try, a python based web framework. I was completely blown away! Compared to the PHP frameworks I’d worked with, such as Cake, it was just so much more of a pleasure to work with. So here are 8 reasons why you should give Django a try yourself if you haven’t already. You won’t be disappointed!
1. Great Documentation
The Django documentation is well written, extremely comprehensive, and up to date. The official documentation contains details API references, loads of relevant examples, and tutorials for those getting started. If that isn’t enough there’s also a whole book that’s available for free online.
2. It’s Python
The fact that it’s Python is a huge plus point for me. It’s a great language that doesn’t suffer from many of the well documented inconsistencies that PHP does, and includes some nice features such as decorators and first-class functions. Going back to PHP you soon start to miss the little things, such as the ability to assign multiple values at once, and the simplicity of slicing lists.
3. The ORM
Django’s object relational mapper completely abstracts away the database, meaning you don’t need to worry about your database schema or constructing SQL queries. If you’re using to writing SQL queries then the QuerySet API takes a little getting used to, but it’s really worth the effort. Projects like South make the ORM even more powerful, allowing you to make schema changes and data migrations automatically.
4. Built in Development Server
Where PHP really shines is on its ease of deployment. Setting up a local development server can be a bit of a pain though, especially if you’re working on several different sites. Django comes with a built in development server though, so you can be up and running within minutes! From your project’s root directory you just do
./manage.py runserver
and access your django website from http://localhost:8000 – awesome!
5. The Admin Interface
Django’s built-in admin interface is practically a full blown CMS, allowing you to add, delete or update your data. It’s pretty much all automatic, but it’s also fairly configuration. See the documentation to see what it can do!
6. Reusable Applications
Django projects are broken up into “applications”, and there are lots of existing reusable applications that you can use for your own projects, such as those for user registration, facebook integration, blogging, and many many more.
Existing applications are great, but the whole project/application distinction also forces you to think about your own project structure and therefore more likely to make reusable components that you can use in more of your own projects, or even share for others to use.
7. Templates
I’ve always been a bit dubious about the merits of PHP template engines such as Smarty. The Django template layer is great though. The inheritance model works well, and the restrictive language really forces you to have a very clean separation of presentation and logic.
8. Forms
I usually find dealing with user input one of the most boring parts of web development. It takes time to get it right, and its repetitive. The Django Form API really simplifies things. You can define your form class, include and validation rules, and simply add a few lines to your template and few lines to your view and you’re done!
So those are my 8 reasons why you should give django a go. If you’re already a django user let me know if you have any points to add!
Nice read.
Maybe some day i’ll give it a try.
But in the meantime, I suggest you try the PHP framework Symfony. It has nothing to see with cakePhp.
Almost all the things you list here apply to symfony
cheers,
zupert
Comment by zupert — January 7, 2010 @ 8:02 am
Exchange “Python” with “Ruby”, and “Django” with “Rails”.
Both Rails and Django are to good frameworks. Give both a good look, and see which one fits your development methodologies best. Ruby on Rails fits me best.
Comment by Torstein — January 7, 2010 @ 3:54 pm
hi,
Like how you like the Django Forms I like it as well. It seems that you’re coming from PHP? And if it is, that’s nice!
Comment by James Caihaibin — January 7, 2010 @ 11:05 pm
> Going back to PHP you soon start to miss the little things, such as the ability to assign multiple values at once
$v = array(‘a’, ‘b’, ‘e’);
list($a, $b, $e) = $v;
print “a=$a, b=$b, e=$e”;
But yeah, you do write more and we’re not getting any younger =)
Comment by Daniel — January 8, 2010 @ 9:07 am
Nice post, and I totally agree with putting documentation as number 1.
Just a very small comment : there is a mistake in you subtitle : Addicited ???
Comment by Jean-Henri — January 8, 2010 @ 11:27 am
Hi Jean-Henri,
Thanks for pointing out the typo. Can’t believe I didn’t see it sooner!
Ben
Comment by Ben — January 8, 2010 @ 11:30 am
Seems to be interesting, I might give it a try one day, that’s a promise.
Comment by MadGeek — January 8, 2010 @ 10:03 pm
@Torstein Why always after a nice Python/Django blog or article pops up the Rails zealots. It is getting old that really. We dont care if you like more Rails, The author is making a point on Django that it is more easy to work with than PHP. So bring your zealotry to another places. Thats why I dont like Rails ecosystem, it sucks with so many arrogant’s in there.
Comment by OtengiM — January 9, 2010 @ 8:45 pm
If you can find the time give web2py a try. I’d be interested in your thoughts on it also.
Comment by Brian — January 10, 2010 @ 4:04 am
One more reason – the community. Django has a wonderful community (which is not surprising given the good reputation of the Python community).
Comment by ZeevB — January 13, 2010 @ 11:49 am
I came to Django from another direction (though I’ve plenty of time in the trenches with PHP): I came from Zope/Plone and was fed up with the overhead, convoluted development process, and total lack of documentation. Django was a breath of fresh air. Simple to get up and running, provides enough scaffolding to support whatever you want to do, then pretty much stays out of your way.
Comment by Rev Matt — January 13, 2010 @ 4:42 pm
Nice post. Django is perfect framework
Comment by SMiGL — January 25, 2010 @ 1:29 pm