Given the following models implemented in sqlite3
class Parent(models.Model):
pass
class Children(models.Model):
parent=models.ForeignKey(Parent,primary_key=True)
After importing the data from the spreadsheet into "Children" I need to get a list of parents who do not have children, and for this I use ...
Parent.objects.filter(children__isnull=True)
which seems to be working fine.
But since referential integrity is not applied, I also need a list of children who do not have a parent, and for this I try ...
Children.objects.filter(parent__isnull=True)
which returns an empty request, although some of them are orphans? Any pointers to the best way to achieve this will be very helpful.
By the way, I know that I can pick up orphans during the import process, but this is not very suitable for my purpose.