django - query filter on manytomany is empty
print TestModel.objects.filter(manytomany=None)
Adding to @Bernhard answer, other possible solution can be achieved using the Q()
object.
from django.db.models import Q
filters = Q(manytomany=None)
TestModel.objects.filter(filters)
Negation:
filters = ~Q(manytomany=None)
TestModel.objects.filter(filters)