I have the following table structures:
class Tags:
name = fields.CharField(max_length=100)
ref = models.ManyToManyField(RefTags)
class RefTags
foo = varchar(128)
tag = models.ForeignKey('Tag')
How can I do a delete from Tags if there are no associated records in RefTags?
Thanks
Edit: I figured it out, it was really easy:
Tag.objects.filter(ref__isnull=True).delete()
Something like
It probably would be more efficient to put RegTags.objects.all() in a list, cycle through it and then do the deletion.