If i have two models:
Model_1.objects.all()
Model_2.objects.all()
Model_1 contains all the elements, Model_2 contains a part of these elements.
How can i find the elements contained in Model_1 but not in Model_2?
I tried:
Model_1.objects.exclude(pk=Model_2.objects.order_by('pk'))
It doesn’t work.
2
Answers
You can use
in[Django doc.]
like:Generally, 2 models represent two different entities. But if you want to filter the Model_1 based on some property of Model_2
Use exclude and filter as per your requirement.