Django - Why

django

What is django?

Django is a high-level Python Web framework (MVC or MTV) that encourages rapid development and clean, pragmatic design. Built by experienced developers, it takes care of much of the hassle of Web development, so you can focus on writing your app without needing to reinvent the wheel. It’s free and open source.

Why should we use django versus rails?

Convention-over-configuration or explicit is better than implicit. With CoC you get automatic imports, controller instance variables are automatically passed to the view and writing tests is convenient. With explicit is better than implicit, it’s always obvious what the code is doing, even for those not familiar with it.

From my personal experience I prefer Django. I like Python’s explicitness and I love Django’s forms and the fact that the framework is more defensive (limited template language, null not enabled by default on model fields). I know however plenty of folks that can’t live without Rails’ magic and its superior testing environment.

Why should we use django instead of other frameworks? What are the main advantages or key features offered by django?

  1. The admin interface: Instead of generating the web site like RoR (you never use because it is too generic), Django have an administration website. This is like phpMyAdmin where admin can edit entities. Django’s admin will blow your mind. The most boring part of writing content-heavy websites is developing admin interfaces. How many times have you written a form validation function? Well, Django’s admin is the most amazing thing to happen to content-driven sites since the invention of the database itself.
  2. MTV / MVC, and ORM
  3. Built-in support for authentication
  4. Built-in support for internationalization
  5. Pluggable applications / modules
  6. Support for middle-ware
  7. Sessions
  8. Caching
  9. Template engine: In Django we have templates, you can define a generic one (for header and footer for example) and get it included in other parts of your website. For us, this was THE concept.
  10. The Django community is amazing and supportive
  11. Django plays well with designers.
  12. Ridiculously fast. Django was designed to help developers take applications from concept to completion as quickly as possible.
  13. Reassuringly secure. Django takes security seriously and helps developers avoid many common security mistakes.

Deployment is a breeze. The web framework world is full of sad tales of deployment woes. You can even read horror stories about deploying Rails, the leader of the dynamic web framework pack.

Django is fast. I’ve seen benchmarks that peg Django’s template language at four times faster than Kid and six times as fast as Cheetah. In fact, it’s SO fast that we’ve found that caching compiled templates is actually slower than re-rendering them on every request.

Django’s ORM is similarly extremely careful to perform as few database lookups as possible, and to always make it obvious when database hits are happening.

What can django ORM do for us?

The ORM is an incredibly powerful database tool. It handles creation of your database, as well as insert, update, delete queries and some quite advanced querying - although it's not perfect. It supports multiple databases - MySQL, PostgreSQL, Oracle & SQLite are all supported out-of-the-box assuming you have the relevant Python libraries installed.

What can django Form do for us?

Forms are not the most fun thing. While Django doesn't make them fun, it at least does a lot for you. You define some fields and how you want the basic validation to work, and Django creates the HTML adds the error messages and cleans the data so you don't get anything unexpected. The Django forms framework can even generate and update your database from a database model you create, make your job even easier.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License