Is there a way to filter globally a Django model? We need to set a filter in a single place so that it gets applied in all queries generated by Django ORM including related objects lookups etc. Example:
class A(Model):
n = IntegerField()
class B(Model):
a = ForeignKey(A)
We want to set on A a global filter id__gte=10 (static to make it simple). The filter must be then automatically applied also when doing related queries, e.g.
B.objects.filter(a__n=123) # this code cannot be modified
should expand somehow magically to an equivalent of
B.objects.filter(a__n=123, a__id__gte=10)
We can change models, managers, querysets but we cannot change the code where objects are actually queried (a lot of code, third party apps, generic API).