Here is the problem: I have two models Contact and Title.
- Contact represent a person
- Title represent a job title
A person can have more than one job title and the two models are related through a many to many relation (see models below).
The issue is that for some reason when I make this query contacts = Contact.objects.filter("some filter").order_by('title') I get contacts with more than one title returned multiple times...because I am ordering by title and I guess django is confused on which title to use? I am losing my mind on how to fix it while keeping ordering by title.
class Title(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
title_name = models.CharField(max_length=40)
class Contact(models.Model):
name_surname = models.CharField(max_length=60)
title = models.ManyToManyField(Title)
...