A reluctant foray into the world of blogging.

Django RESTful resources

Last year I blogged about a neat trick in Django to have multiple views per HTTP verb. Since then I’ve been playing with RESTful applications and decided to see if there was a nicer way to expose “resources” in Django. The following is what I’ve come up with so far.

It does add a little bit more magic to the views (since you don’t actually see the dispatch method at all) but it benefits from simpler mapping in urls.py, as well as an easier way to figure out what instance method on a Resource subclass gets called for each HTTP verb. Never felt that comfortable with popping-off of kwargs in last year’s post.

This entry was posted on 8 February 2010, 12:34 am and is filed under My Code, Software Development. You can follow any responses to this entry through RSS 2.0.
You can skip to the end and leave a response. Pinging is currently not allowed.

@Andriy Thanks for the link. What I was after was not a filter but a way of dispatching the same URL to different handler methods based on a HTTP verb. If I wanted to restrict which HTTP verbs I support on a single handler method then the filter makes great sense.