Skip to content

Instantly share code, notes, and snippets.

View kiawin's full-sized avatar

Sian Lerk Lau kiawin

View GitHub Profile
class CustomQuerySetManager(Manager):
"""
A re-usable Manager to access a custom QuerySet
"""
def __getattr__(self, attr):
# don't delegate internal methods to queryset
# NOTE: without this, Manager._copy_to_model will end up calling
# __getstate__ on the *queryset* which causes the qs (as `all()`)
# to evaluate itself as if it was being pickled (`len(self)`)
if attr.startswith('__'):