Skip to content

Instantly share code, notes, and snippets.

@gustavofonseca
Created April 23, 2012 22:25
Show Gist options
  • Save gustavofonseca/2474273 to your computer and use it in GitHub Desktop.
Save gustavofonseca/2474273 to your computer and use it in GitHub Desktop.
django caching machine no scielo manager
import caching.base
class AppCustomManager(models.Manager):
"""
Domain specific model managers.
"""
def available(self, availability=None):
"""
Filter the queryset based on its availability.
"""
data_queryset = caching.base.CachingQuerySet(self.model) #usa o queryset cacheado
if availability is not None:
if not isinstance(availability, bool):
data_queryset = data_queryset.filter(is_available=availability)
return data_queryset
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment