summaryrefslogtreecommitdiff
path: root/docs/ref/models
diff options
context:
space:
mode:
authorAndrew Godwin <andrew@aeracode.org>2013-06-28 17:32:57 +0100
committerAndrew Godwin <andrew@aeracode.org>2013-06-28 17:32:57 +0100
commit7a47ba6f6aeca36b8b092dbafd36abb342d34d4b (patch)
treee959922f7d4d08057225459e31697f410e26df26 /docs/ref/models
parente2d7e83256234251a81ad3388428f6579795a672 (diff)
parent48dd1e63bbb93479666208535a56f8c7c4aeab3a (diff)
Merge remote-tracking branch 'core/master' into schema-alteration
Conflicts: django/db/backends/__init__.py django/db/models/fields/related.py tests/field_deconstruction/tests.py
Diffstat (limited to 'docs/ref/models')
-rw-r--r--docs/ref/models/fields.txt22
-rw-r--r--docs/ref/models/instances.txt7
2 files changed, 27 insertions, 2 deletions
diff --git a/docs/ref/models/fields.txt b/docs/ref/models/fields.txt
index 8146dfd341..f5c1058b17 100644
--- a/docs/ref/models/fields.txt
+++ b/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
+
+ .. versionadded:: 1.6
+
+ Same as :attr:`ForeignKey.related_query_name`.
+
.. attribute:: ManyToManyField.limit_choices_to
Same as :attr:`ForeignKey.limit_choices_to`.
diff --git a/docs/ref/models/instances.txt b/docs/ref/models/instances.txt
index cfc95db092..17c9aa9fb7 100644
--- a/docs/ref/models/instances.txt
+++ b/docs/ref/models/instances.txt
@@ -679,8 +679,11 @@ For every :class:`~django.db.models.DateField` and
returns the next and previous object with respect to the date field, raising
a :exc:`~django.core.exceptions.DoesNotExist` exception when appropriate.
-Both methods accept optional keyword arguments, which should be in the format
-described in :ref:`Field lookups <field-lookups>`.
+Both of these methods will perform their queries using the default
+manager for the model. If you need to emulate filtering used by a
+custom manager, or want to perform one-off custom filtering, both
+methods also accept optional keyword arguments, which should be in the
+format described in :ref:`Field lookups <field-lookups>`.
Note that in the case of identical date values, these methods will use the
primary key as a tie-breaker. This guarantees that no records are skipped or