8 Reasons Why You Should Try Django


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

./ 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!

Django works with any open source hosting. You can always go for reseller web hosting.

Posted on 06 Jan 2010
If you enjoyed reading this post you might want to follow @coderholic on twitter or browse though the full blog archive.