Skip to content

Entries published on December 11, 2007

1 entry published on this date. See also: all entries published in December 2007, full archive.

Requiring HTTP methods

Just a quick tip today: someone on IRC tonight was asking for an easy way to write a Django view which restricts itself to only allowing a specific HTTP method or methods. For example, a web-based API might want to only allow POST to specific views.

This is actually pretty easy to do with a set of decorators built in to Django, in the module django.views.decorators.http. Specifically, the fix for ticket #703 added three useful things to that module:

Entry published December 11, 2007. Read full entry.