class ActiveInactiveManager(models.Manager): """ Used for models with active_date and inactive_date. Adds an "active" filter to get only active items """ def active(self): return self.filter( Q(active_date=None) | Q(active_date__lte=now), Q(inactive_date=None) | Q(inactive_date__gt=now) ) # Usage in model: class MyModel(models.Model): #... active_date = models.DateField() inactive_date = models.DateField() objects = ActiveInactiveManager() """ # usage example >>> MyModel.objects.active() >>> MyModel.objects.active().filter(category='whatever') """