from datetime import datetime from django.db import models from django.db.models.query import QuerySet class PostMixin(object): def by_author(self, user): return self.filter(user=user) def published(self): return self.filter(published__lte=datetime.now()) class PostQuerySet(QuerySet, PostMixin): pass class PostManager(models.Manager, PostMixin): def get_query_set(self): return PostQuerySet(self.model, using=self._db) class Post(models.Model): user = models.ForeignKey(User) published = models.DateTimeField() objects = PostManager() Post.objects.by_author(user=request.user).published()