Django doc says:
ForeignKey.related_query_name
New in Django 1.6.
The name to use for the reverse filter name from the target model. Defaults to the value of related_name if it is set, otherwise it defaults to the name of the model:
# Declare the ForeignKey with related_query_name
class Tag(models.Model):
article = models.ForeignKey(Article, related_name="tags", related_query_name="tag")
name = models.CharField(max_length=255)
# That's now the name of the reverse filter
article_instance.filter(tag__name="important")
However, an object model doesn't have filter() method. I am trying to use related_query_name to filter a model M with a condition on the related objects R. The problem is that result includes instances of M which don't have related objects in R. But I would like to first understand what related_query_name is. Could someone explain? Thanks,
Petr