Feed Sign in with OpenID OpenID

Simon Willison’s Weblog

Introducing Django

You may know that I spent a year working in Kansas for a local newspaper—the Lawrence Journal-World. I’m delighted to announce that a decent chunk of the software I worked on there is now available as open-source, in the form of the Django web framework.

Django is an MVC Python web development framework with a strong emphasis on content management. While comparisons with Rails are inevitable (I plan to post one myself shortly), it should be emphasized that Django is by no means a clone of Rails—in fact, development on Django started in October 2003, months before the first public Rails release. That the two frameworks share so many ideas is, I feel, a testament to the design of both.

Django was initially developed by Adrian Holovaty and myself, with Jacob Kaplan-Moss joining the team shortly before my departure. The framework evolved during the construction of a number of sites, which included:

  • 6newslawrence.com, local TV news, the first site to launch using the then nascent Django framework.
  • lawrence.com, a local entertainment site. Every town should have a site like this; sadly, very few do.
  • VisitLawrence.com, a local tourism site.
  • KUSports.com, a sports news site covering the University of Kansas.
  • LJWorld.com, a local news site and the flagship for the Journal-World.

It’s also purring along under the hood of chicagocrime.org and the Django project site itself.

Adrian and I developed Django to allow us to create reasonably complex database driven web applications in as little time as possible. A local newspaper produces a huge amount of information—news stories, events listings, obituaries, sports results, marriage announcements, photo galleries, polls, weather reports and dozens of other bits and pieces. To maximise their value and potential for reuse, these things need to be stored in a database. That database needs a user interface for people to add and modify content, and of course the information needs to be published to a website somewhere.

Django automates most of this—and makes the rest as easy as possible. You create a data description (kind of like an SQL table schema but with additional information about validation rules and interface widgets) and load it in to Django. Django then creates the database tables, model classes and a comprehensive web-based administration interface for your site’s staff. All that’s left for you to do manually is the code for the public site, which is generally a case of writing a few lines of controller code, configuring some URLs and knocking out some templates.

To give you an idea of how much this speeds up the creation of new sites, consider the case of Game. Game was a site created to provide detailed coverage of little-league games in and around Lawrence (for non-Americans, little-league is baseball and softball for children aged around 5 to 11—it’s amazingly popular). The entire Game site, including news, fixtures, match results, team profiles and even weather forecasts for forthcoming matches took two days to develop.

I haven’t been involved with Django since leaving the Journal-World back in September, but now that the framework is open-sourced I look forward to contributing to its further development—both in terms of documentation and actual code. There’s already plenty to look at on the Django site (designed by the ever-talented Wilson Miner); I suggest the overview as your first port of call.

Expect to hear a lot more about the framework in the next few weeks.

This is Introducing Django by Simon Willison, posted on 17th July 2005.

Tagged

View blog reactions

Next: Understanding the Greasemonkey vulnerability

Previous: Less code is more

18 comments

  1. Interesting to find that Django, given its relative likeness to Rails, was also extracted from a real-world app, created by necessity of building good apps fast, as opposed to out of the aspiration to create a framework.

    Tomas Jogin - 17th July 2005 13:05 - #

  2. Looks very solid, great work Simon. Looking forward to see WSGI implemented soon.

    Mike - 17th July 2005 13:07 - #

  3. Contratulations on the release, very impressive work. So far I'm enjoying playing with it. Multiple server choices will definitely help adoption, even if most people will use Apache and mod_python in production. One of the reasons I think CherryPy is so enjoyable to work with, for example, is that the server piece is trivial and automatic. Likewise PHP.

    Speaking of which, I've been wondering: do you think your PHP background was a significant influence in your work on Django? Certainly the templating language has a very Smarty-ish flavor (a good thing IMO). But throughout Django there's evidence of a pragamatism lacking from some of the more "all architecture all the time" Python web frameworks.

    Paul Bx - 17th July 2005 19:12 - #

  4. PHP was definitely an influence in as much as both Adrian and I had spent years working with it and trying to get it to do things the way we wanted. Switching to Python gave us the flexibility we needed to pull everything off. I'm pretty sure the same is true of David Heinemeier Hansson and Rails.

    Simon Willison - 17th July 2005 19:55 - #

  5. Wonderful! Congratulations.

    Ping - 17th July 2005 21:52 - #

  6. Jesus. Another framework. Yawn.

    J Breen - 18th July 2005 00:41 - #

  7. Jesus. Another troll. Yawn.

    Jeremy Dunck - 18th July 2005 05:49 - #

  8. Great, finally :) I have been watching your wfw for a while and believe that this will be the killer ONE.

    And now it needs just more marketing (in order to compete with Rails).

    And to be honest - django website is at www.djangoproject.com, yet the logo is just django.

    rdk - 18th July 2005 09:26 - #

  9. I'm a PHP developer and I've created a pretty good framework for myself over the years that I'm pretty comfortable with. However, I like to look at other frameworks for ideas and I like to be open to the idea that I might just find a framework that would make me want to just drop mine entirely. I will be sure to do some investigating. I hope it's not as hard to install on my Powerbook at Ruby on Rails as been (still haven't got it going). I have a natural affinity to Django because you worked on it while in Kansas and I currently live and work in Kansas. Although you did live in a rival town! I'm the web manager for http://www.capd.ksu.edu.

    At any rate I have some questions that maybe you could answer in your next article about Django or in the comments?

    1. What are the advantages over using Python over PHP and Ruby?
    2. What are the advantages of Django over Ruby on Rails?
    3. What do you say to those bigots that won't give it the time of day because it's not Java or .Net?

    Brent O'Connor - 18th July 2005 16:18 - #

  10. Simon, Wilson, Adrain, Lawrence.com, KUSports.com, 6news, etc. Wow! Kansas, represent!

    Jeff Croft - 18th July 2005 17:14 - #

  11. For the record, Brent meant me as a .NET bigot. :) My point was: every framework works best with the specific task(s) it was designed for. For example, Mike Davidson wrote about them using Java Tea and Kettle at Disney. I liked thier scripting language, but it would've taken quite a bit of effort to retrofit it to a blog, for example.

    Still, I'm curious to see what you say to Brent's other two questions.

    Milan Negovan - 18th July 2005 20:14 - #

  12. I'm pretty excited about django, from the tutorials and testimonials; with WSGI support and maybe a sqlite backend, it might become enough of an "instantly out of the box" platform to dominate (I have three or four things I really want to try in it and have been hampered by *not* having a big-infrastructure database around to try it on; it's not a *large* energy barrier, but it is one.)

    However, the references to learning from PHP worry me a great deal - since, from my (highly jaded) perspective, PHP is a great platform to write security holes in! By this point I'd expect framework designers to realize that "cross-site scripting exploits" need to be averted by default, just from the continuous stream of "oops, another big PHP app exploited" messages that have gone by. I haven't seen this mentioned, does anyone know if it's been considered? (Or is otherwise a non-issue that I shouldn't be worrying about?)

    Mark Eichin - 19th July 2005 00:45 - #

  13. Mark: One of the things we learnt from PHP was how to make writing security holes harder! I'm not saying you can't create them in Django, but the two most common (XSS and SQL injection) have counter-measures built in to the framework.

    On to Brent's questions:

    1. What are the advantages over using Python over PHP and Ruby?

      I'd say Python and Ruby are pretty much neck and neck - they're both superbly well designed languages, they both have good standard libraries. Python just beats out Rails on size of community and available code for doing cool things, but Ruby's catching up pretty fast there.

      PHP on the other hand has some serious problems - the most noticable being the lack of namespaces or modules which makes building large applications hard and integrating lots of code from other people a mine field. While it beats Python and Ruby on deployability (virtually every web host supports it these days) it loses out in the language design stakes. I think you'll find it hard to find anyone - even the most ardent of PHP hackers - who will claim that the language itself is better designed than Ruby or Python.

    2. What are the advantages of Django over Ruby on Rails?

      I'm going to write more about this shortly, but right now Django's two advantages are that it's Python (hence slightly bigger community and availability of cool code) and that it comes from the CMS world, so it handles the creation of boring administration screens for you. Rails has scaffolding but it's not meant as a final interface. Rails has plenty of advantages over Django - like the fact that Rails isn't a pre-release "hackers and early adopters only" project right now!

    3. What do you say to those bigots that won't give it the time of day because it's not Java or .Net?

      Go read lesscode.org ;) Dynamic languages offer productivity gains over their static cousins. If you don't believe this, it's your loss!

    Simon Willison - 19th July 2005 03:19 - #

  14. Thanks for the link, Simon. Will keep an eye on it.

    Milan Negovan - 19th July 2005 16:46 - #

  15. Hey, just a heads up, Simon, I submitted this post and the Django site to Slashdot...so if the story gets accepted you may get slashdotted. Good luck.

    Daniel Talsky - 19th July 2005 19:15 - #

  16. Simon,

    Thanks for the reply. BTW, it was nice meeting you at SXSW 2005. I'm going to really have to dig in to Python and Django soon.

    It would be cool for you to share some of these community websites that are out there for Python. I've looked at Python a little bit and one thing that I don't like is that the main website for Python.org just plain stinks and I don't think it is as near as good as php.net. That's just my humble opinion though.

    Milan,

    I wasn't referring to just you... I know other Java and .Net bigots. I work at a University remember! :)

    Brent O'Connor - 21st July 2005 14:20 - #

  17. I submitted this story to slashdot and it was accepted (doesn't seem like Daniel's got through). This will be the ultimate performance test I suppose.

    James Dam - 2nd August 2005 02:06 - #

  18. I definitely need to take a close look at Django if it can approach the producti...

    John - 8th May 2006 21:11 - #

Comments are closed.

Previously hosted at http://simon.incutio.com/archive/2005/07/17/django

A django site