Skip to content

Instantly share code, notes, and snippets.

View sehmaschine's full-sized avatar

Patrick Kranzlmueller sehmaschine

View GitHub Profile
@sehmaschine
sehmaschine / export.py
Created March 2, 2013 13:54
celery update_state issue
from tasks import full_export_task
def export_year_zip(user):
full_export_task.update_state(state="PROGRESS", meta={})
@dpnova
dpnova / gist:1223933
Created September 17, 2011 13:26
invalidate cache_page entries in django
def expire_view_cache(view_name, args=[], namespace=None, key_prefix=None, method="GET"):
"""
This function allows you to invalidate any view-level cache.
view_name: view function you wish to invalidate or it's named url pattern
args: any arguments passed to the view function
namepace: optioal, if an application namespace is needed
key prefix: for the @cache_page decorator for the function (if any)
from: http://stackoverflow.com/questions/2268417/expire-a-view-cache-in-django
added: method to request to get the key generating properly
@toastdriven
toastdriven / autocomplete.py
Created February 21, 2011 19:12
How to make multiple word autocomplete work in Haystack.
import operator
from haystack.query import SearchQuerySet, SQ
query = 'lil way'
sqs = SearchQuerySet().filter(reduce(operator.__and__, [SQ(name=word.strip()) for word in query.split(' ')]))