djangosnippets.org: Latest snippets posted by dottedmaghttp://djangosnippets.org/users/dottedmag/2007-07-11T10:54:09.642283-05:00dottedmagMiddleware that fixes URLs generation for admin and {% url %} for SCGI and WSGI
2007-07-11T10:54:09.642283-05:00dottedmaghttp://djangosnippets.org/snippets/307/<p>This middleware fixes generation of URLs for admin interface and {% url %} resolving when you're mounting application to the subtree of site, e.g. if you use SCGIMount /prefix/ and serve application using SCGI, or if you use WSGI and want to bind Django application to some prefix.</p>
Freely redistributableHTTP headers view decorator
2007-06-10T13:08:21.502981-05:00dottedmaghttp://djangosnippets.org/snippets/275/<p>Decorator adding arbitrary HTTP headers to the response.</p>
<p>This decorator adds HTTP headers specified in the argument (map), to the
HTTPResponse returned by the function being decorated.</p>
<p>Example:</p>
<p>@headers({'Refresh': '10', 'X-Bender': 'Bite my shiny, metal ass!'})
def index(request):
....</p>
Freely redistributableQLeftOuterJoins
2007-06-10T12:54:12.727660-05:00dottedmaghttp://djangosnippets.org/snippets/274/<p>This hack replaces all INNER JOINs inside to the LEFT OUTER JOINs (see http://code.djangoproject.com/ticket/3592 for explanation).
</p>
<p>Use: QLeftOuterJoins(Q(...) | Q(...) & (Q(...) | ....)).
</p>
Freely redistributableQEmpty
2007-06-10T12:51:29.799665-05:00dottedmaghttp://djangosnippets.org/snippets/273/<p>Q() value in Django is identity for & operation: Q() & foo & bar & ... == foo & bar & ...</p>
<p>QEmpty() is complimentary identity for | operation: QEmpty() | foo | bar | ... == foo | bar | ...</p>
<p>QEmpty() itself returns empty queryset.</p>
<p>Handy for complex …</p>
Freely redistributable