Noob Django ORM question here:
I have a model similar to this:
class Company(models.Model): id = models.PositiveIntegerField(null=False, blank=False, primary_key=True) name = models.CharField(max_length=255, null=True, blank=True, default="") class Audited(models.Model): company = models.ForeignKey( Company, null=False, blank=False, on_delete=models.CASCADE, related_name="logs" ) city = models.CharField(null=False, blank=False, max_length=255) I have been scratching my head with this problem and I can not figure out how to solve it.
Given a city, I need the company that do not have been audited on that city, so basically the Company who does not have a record on Audited with that city.
So for example, if the city is New York, and there is no record in Audited with a company like Oracle and city as New York, I receive Oracle.
It is very confusing to me because the ORM appears to have been designed for positive relations, like "the item from table A who has a record on Table B", and this is precisely the opposite. Any clue of how can I do this?