Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Docs for related_query_name

  • Loading branch information...
commit 12cb0df10f12e715bcaafbee4290c92d4ed6f111 1 parent b21e96d
@andrewgodwin andrewgodwin authored
Showing with 22 additions and 0 deletions.
  1. +22 −0 docs/ref/models/fields.txt
View
22 docs/ref/models/fields.txt
@@ -1083,6 +1083,22 @@ define the details of how the relation works.
user = models.ForeignKey(User, related_name='+')
+.. attribute:: ForeignKey.related_query_name
+
+ .. versionadded:: 1.6
+
+ The name to use for the reverse filter name from the target model.
+ Defaults to the value of :attr:`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")
+
.. attribute:: ForeignKey.to_field
The field on the related object that the relation is to. By default, Django
@@ -1207,6 +1223,12 @@ that control how the relationship functions.
users = models.ManyToManyField(User, related_name='u+')
referents = models.ManyToManyField(User, related_name='ref+')
+.. attribute:: ForeignKey.related_query_name

Apologies if I have this wrong as I am new to Django, but this is a typo, right? (should be ManyToManyField.related_query_name ?)

@andrewgodwin Owner

You're right; I'll patch it. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+
+ .. versionadded:: 1.6
+
+ Same as :attr:`ForeignKey.related_query_name`.
+
.. attribute:: ManyToManyField.limit_choices_to
Same as :attr:`ForeignKey.limit_choices_to`.
@rosnfeld

Apologies if I have this wrong as I am new to Django, but this is a typo, right? (should be ManyToManyField.related_query_name ?)

@andrewgodwin

You're right; I'll patch it. Thanks!

Please sign in to comment.
Something went wrong with that request. Please try again.