Skip to content

Instantly share code, notes, and snippets.

@epicserve
Created August 31, 2012 22:44
Show Gist options
  • Save epicserve/3560364 to your computer and use it in GitHub Desktop.
Save epicserve/3560364 to your computer and use it in GitHub Desktop.
People Manager
from django.db.models import Manager
class PeopleManager(Manager):
"""Returns published objects that are not in the future."""
def active(self):
return super(PeopleManager, self).get_query_set().filter(is_active=True)
def staff(self):
return super(PeopleManager, self).get_query_set().filter(is_active=True, is_staff=True)
def has_responsibility(self, responsibility):
return super(PeopleManager, self).get_query_set().filter(is_active=True, is_staff=True).filter(responsibilities__slug=responsibility)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment