Django – First Impression

6

Category : Django

I spent this weekend checking out Django.

I have been wanting something for personal projects for rapid development.

I am a strong believer in using whatever works best for the task at hand.

First, a little background:

We use Symfony where I work. While symfony is great, it is very resource intensive (we run a few dozen ecommerce sites with a database holding around 200 tables storing many gig of data) – so, in reality symfony really does fit the project. The downside is everything is running on multiple, mulitcore servers sitting on 8 to 16 Gig of memory.

While I cannot justify a beefy server setup for my own (or a clients) project, I do enjoy the benefits of using a framework.

I have been developing with the Zend Framework for outside projects and really do like the features available, but the biggest thing Zend is missing is a crud generator (I have even started building my own).

In my latest search to see what was out there, I came across a post comparing Symfony, RoR, and Django here. Like any opinion, it must be read with a grain of salt. I can however relate to the performance mentioned regarding the symfony framework. From past readings I was not very interested in RoR, so that left Django (which from the poster had the best performance).

Checking it out:

I did a quick scan over Django’s website, and feature list. Next I read the installation guide and the first page on the tutorial. Normally I can get a decent impression from simply ready a tutorial, but Django was not quite that way… But I got a good vibe from the feature list and the opinions for other bloggers, so I decided to take an existing vmware install and setup Django.

Django is a python framework, python is already included with many linux distro’s, so nothing to install for that. For Django it’s 3 simple steps:

  • download Django.
  • untar the downloadable file.
  • run the install script.

That’s it!

For the first half of the tutorial, most of the work is done in the terminal – creating the project, setting up the database tables, modules, etc (alot like symfony).

Django also has an interactive python shell that integrates with Django’s API (nice for basic queries and such).

The majority of the tutorial is an intro to the *.py files that contain the framework’s settings (such as enabling the admin area). I’ll openly have to say that the admin pages generated are ALOT prettier than symfony’s default (at work we have customized the admin area – thank god) and offer more features and flexibility out of the box than symfony.

Most of the config settings are for what is included in the project and how it’s displayed (what fields, if they’re inside a collapsible div, setting filters and the like).

For example, the tutorial is setting up a Poll with choices. In the section where you add new choices you have a drop down box for which Poll to assign the choice to, Django has a setting so that next to the drop down box, you have an ‘add new’ icon for creating a new poll (which opens in a pop up window), you can also specify how many ‘new fields’ are available (say on the create new choice page, you want to have 3 fields for new entries) – all this is powered by settings in one file!

The file structure layout is very simple and modular.

You have a basic settings.py file, this is where you set your database settings, template dir, and included modules. There is also a urls.py file that basically handles url routing.

In the modules directory (in the example Polls directory), you have an admin.py which tells the admin area how to handle the generated pages for managing the module (display, filters, etc). Next is the models.py which works with the database fields, views.py that deals with the views, and you can also place a urls.py that handles all module related urls for the given module (simply include it in the project’s urls.py file).

My terminology may not be correct, this writeup is after going through the tutorial the first time.

I am not going to give a step-by-step reproduction of the tutorial, but can say I am impressed with what is able to be generated with very little code (a handful of files and non of them have more that 20 lines of code).

Conclusion:

I’ll  have to say, I am really impressed with what I have seen.

Pros:

  • Simple to install.
  • Simple to configure.
  • Common MVC layout.
  • 100% modular.
  • Lightweight
  • Powerful

Cons:

  • Configuration files can be picky due to spacing.
  • Error messages can leave you hunting in the dark for the real error.

This is the first time I have ever worked with python, so it will be somewhat of a learning curve, but I do believe (and others have also said) that the time is well worth the effort.

I have also ready about a few people using Django for the backend (administration area) and php for the frontend. I think this also would be a great middle ground.

Comments (6)

I traveled a similar journey to yourself, except I fell for the RoR trap. I think it’s GREAT marketing, but fails to deliver. Reminds me of Vista’s hype…

Django is great. It just does what it says on the tin. I’m primarily a Java developer, and I must admit that I find myself turning more and more to Django for projects that need to be delivered quickly with fewer developers & designers.

Sure, it’s not perfect, but that Python code is SSSOOOO pretty :)

I have to go now – RoR developers kicking down my door!!! AAARRRGGHH!!

Wow you had much better luck than I did. I found that getting the supporting MySQL packages for Django were very difficult and fussy on Ubuntu.

Hey I did exactly the same path. I even think we’ve read the same article about the speed. I planned to use it for my own applications, but for the sake of stability I decided to start a full time job. I’m now working with Django in serious movie company. It’s connecting to a distributed API using Twisted. I’m stuck with Python – this time for good.

I had before some RoR experience, but it really didn’t “talk to me”. Python is different. Errors are easy to follow as soon as you’ll know Python better.

Thanks for your post. I am new at development and this will be a big help.

Considerably, the blog post is actually the greatest on this worthy topic. I concur with your decisions and will thirstily look forward to see your approaching updates. Saying thanks will not just be adequate, for the phenomenal lucidity in your writing. I will at once grab your feeds to stay informed of any updates. Delightful work and much success in your business endeavors! Have a nice day

Post a comment