Login

Snippets by dottedmag

Snippet List

HTTP headers view decorator

Decorator adding arbitrary HTTP headers to the response. This decorator adds HTTP headers specified in the argument (map), to the HTTPResponse returned by the function being decorated. Example: @headers({'Refresh': '10', 'X-Bender': 'Bite my shiny, metal ass!'}) def index(request): ....

  • http
  • view
  • decorator
  • headers
Read More

QLeftOuterJoins

This hack replaces all INNER JOINs inside to the LEFT OUTER JOINs (see http://code.djangoproject.com/ticket/3592 for explanation). Use: QLeftOuterJoins(Q(...) | Q(...) & (Q(...) | ....)).

  • q
  • query
  • join
  • left
  • outer
Read More

QEmpty

Q() value in Django is identity for & operation: Q() & foo & bar & ... == foo & bar & ... QEmpty() is complimentary identity for | operation: QEmpty() | foo | bar | ... == foo | bar | ... QEmpty() itself returns empty queryset. Handy for complex query generation.

  • q
  • query
Read More

dottedmag has posted 4 snippets.