Login

Snippets by spenczar

Snippet List

Convert Q object to function

This is a function to take a Q object and construct a function which returns a boolean. This lets you use the exact same filter syntax that Django's managers use and apply it inside list comprehensions, or to non-persistent objects, or to objects of different types with the same attribute names.

  • q-objects
  • field
  • queryset
Read More

Caching Decorator

This is a decorator which will gets Django to try the cache before computing the result of a function. It automatically builds the cache key as a hash of the function name and inputs, and allows you to set whatever timeout you want.

  • cache
  • decorator
  • speed
  • caching
  • fast
Read More

spenczar has posted 2 snippets.