The other option is that if you have a filter that you always want applied, to add a custom manager on the model in question which always applies the filter to the results returned.
A good example of this is a Event
model, where for 90% of the queries you do on the model you are going to want something like Event.objects.filter(date__gte=now)
, i.e. you're normally interested in Events
that are upcoming. This would look like:
class EventManager(models.Manager):
def get_query_set(self):
now = datetime.now()
return super(EventManager,self).get_query_set().filter(date__gte=now)
And in the model:
class Event(models.Model):
...
objects = EventManager()
But again, this applies the same filter against all default queries done on the Event
model and so isn't as flexible some of the techniques described above.