Ticket #15932: 15932-docs.diff

File 15932-docs.diff, 1.2 KB (added by Claude Paroz, 12 years ago)

Explain related_name ended with +

  • docs/ref/models/fields.txt

    diff --git a/docs/ref/models/fields.txt b/docs/ref/models/fields.txt
    index 23dcf4b..3c299a9 100644
    a b define the details of how the relation works.  
    10031003    :ref:`some special syntax <abstract-related-name>` is available.
    10041004
    10051005    If you'd prefer Django didn't create a backwards relation, set ``related_name``
    1006     to ``'+'``. For example, this will ensure that the ``User`` model won't get a
    1007     backwards relation to this model::
     1006    to ``'+'`` or end it with ``'+'``. For example, this will ensure that the
     1007    ``User`` model won't get a backwards relation to this model::
    10081008
    10091009        user = models.ForeignKey(User, related_name='+')
    10101010
     1011    As the ``related_name`` attribute must be unique in a model in any case, you
     1012    have to set it to different values each ended with ``'+'`` if you want to
     1013    suppress two backwards relations on the same model::
     1014
     1015        user = models.ForeignKey(User, related_name='u+')
     1016        location = models.ForeignKey(Location, related_name='l+')
     1017
    10111018.. attribute:: ForeignKey.to_field
    10121019
    10131020    The field on the related object that the relation is to. By default, Django
Back to Top