Django on rails: getting resourceful - Zachary Voase (

Tags: djangocon, django

Code is fine, but it needs a concept behind it. A concept is worth nothing if it isn’t backed by code. Django does that pretty well, especially if you look at the models. A model “Artist” and “Album” is pretty clean, conceptually.

Django is not really a MVC (model view controller) framework, it is more MTV (model template view). The model layer has a clear goal and responsibility. Templates have a clear goal and responsibility. It is the views that aren’t so clear. There’s often spagghetti code in there. Glue code, tying it all together. But glue is messy. Long functions. It does help that django has class based views now, but it doesn’t help all the way.

The best way is to get back to basics. To basic concepts. He asked a show of hands who had read I put my hand up, but I was one of the few ones. He was surprised, as that document contains the basic concepts of what we’re all working with on the web.

The number one basic concept on the web is that of a resource. A single blog post is a resource. A weblog is a resource. And so on. He’s added a “resource” concept to django that you can hook up in your The project is called “dagny”. See . This adds a ruby on rails-like restful resource to django. Look at to see what effect it has on the URLs and on the http methods you can call on it. It uses a set of conventions to build up the urls.

The good thing about dagny is that it is pure python.

Most of the view code that he has seen in django projects could be made clearer and cleaner by using the resource concept. Having this extra concept helps making your apps better structured.

My reserve bike (currently being restored) logo

About me

My name is Reinout van Rees and I work a lot with Python (programming language) and Django (website framework). I live in The Netherlands and I'm happily married to Annie van Rees-Kooiman.

Weblog feeds

Most of my website content is in my weblog. You can keep up to date by subscribing to the automatic feeds (for instance with Google reader):