mirror of
https://github.com/django/django.git
synced 2025-06-03 02:29:13 +00:00
Refs #15250 -- Added docstring for ForwardOneToOneDescriptor.
This commit is contained in:
parent
31a9a965a3
commit
3e9f769fd1
@ -78,7 +78,7 @@ from django.utils.functional import cached_property
|
|||||||
class ForwardManyToOneDescriptor(object):
|
class ForwardManyToOneDescriptor(object):
|
||||||
"""
|
"""
|
||||||
Accessor to the related object on the forward side of a many-to-one or
|
Accessor to the related object on the forward side of a many-to-one or
|
||||||
one-to-one relation.
|
one-to-one (via ForwardOneToOneDescriptor subclass) relation.
|
||||||
|
|
||||||
In the example::
|
In the example::
|
||||||
|
|
||||||
@ -265,6 +265,16 @@ class ForwardManyToOneDescriptor(object):
|
|||||||
|
|
||||||
|
|
||||||
class ForwardOneToOneDescriptor(ForwardManyToOneDescriptor):
|
class ForwardOneToOneDescriptor(ForwardManyToOneDescriptor):
|
||||||
|
"""
|
||||||
|
Accessor to the related object on the forward side of a one-to-one relation.
|
||||||
|
|
||||||
|
In the example::
|
||||||
|
|
||||||
|
class Restaurant(Model):
|
||||||
|
place = OneToOneField(Place, related_name='restaurant')
|
||||||
|
|
||||||
|
``restaurant.place`` is a ``ForwardOneToOneDescriptor`` instance.
|
||||||
|
"""
|
||||||
|
|
||||||
def get_object(self, instance):
|
def get_object(self, instance):
|
||||||
if self.field.remote_field.parent_link:
|
if self.field.remote_field.parent_link:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user