Skip to content

Instantly share code, notes, and snippets.

@tkaemming
Created July 29, 2010 16:30
Show Gist options
  • Save tkaemming/498585 to your computer and use it in GitHub Desktop.
Save tkaemming/498585 to your computer and use it in GitHub Desktop.
from django.db import models
class CustomQuerySetManager(models.Manager):
use_for_related_fields = True
def __init__(self, queryset, *args, **kwargs):
super(CustomQuerySetManager, self).__init__(*args, **kwargs)
self._queryset = queryset
def get_query_set(self):
return self._queryset(self.model, using=self._db)
def __getattr__(self, attr):
try:
return getattr(self.__class__, attr)
except AttributeError:
return getattr(self.get_query_set(), attr)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment