djangosnippets.org: Latest snippets posted by schinckelhttp://djangosnippets.org/users/schinckel/2009-09-08T03:11:02.807398-05:00schinckelHTTP Authorization Middleware/Decorator
2009-09-08T03:11:02.807398-05:00schinckelhttp://djangosnippets.org/snippets/1720/<p>Use HTTP Authorization to log in to django site.</p>
<p>If you use the FORCE_HTTP_AUTH=True in your settings.py, then ONLY Http Auth will be used, if you don't then either http auth or django's session-based auth will be used. This assumes that the regular auth middleware is already installed.</p>
<p>If you …</p>
Freely redistributableDecorator that limits request methods
2009-07-25T03:45:14.988508-05:00schinckelhttp://djangosnippets.org/snippets/1651/<p>I wanted to be able to limit which types of requests a view will accept. For instance, if a view only wants to deal with GET requests.</p>
<pre><code>@methods(GET)
def index(request):
# do stuff
</code></pre>
<p>Now, calling this view with a non-GET request will cause a 403.</p>
<p>You can easily change this …</p>
Freely redistributable