1
0
mirror of https://github.com/django/django.git synced 2024-12-23 01:25:58 +00:00

Corrected examples in related field descriptor docstrings.

Using lowercased model class names suggested that accessing the attribute
from instances of the class returned an instance of the descriptor, but
this is only the case when accessed from the model class.
This commit is contained in:
Simon Charette 2017-10-13 12:27:59 -04:00 committed by Tim Graham
parent 216eda103b
commit 9dd405973c

View File

@ -79,7 +79,7 @@ class ForwardManyToOneDescriptor:
class Child(Model): class Child(Model):
parent = ForeignKey(Parent, related_name='children') parent = ForeignKey(Parent, related_name='children')
``child.parent`` is a ``ForwardManyToOneDescriptor`` instance. ``Child.parent`` is a ``ForwardManyToOneDescriptor`` instance.
""" """
def __init__(self, field_with_rel): def __init__(self, field_with_rel):
@ -254,7 +254,7 @@ class ForwardOneToOneDescriptor(ForwardManyToOneDescriptor):
class Restaurant(Model): class Restaurant(Model):
place = OneToOneField(Place, related_name='restaurant') place = OneToOneField(Place, related_name='restaurant')
``restaurant.place`` is a ``ForwardOneToOneDescriptor`` instance. ``Restaurant.place`` is a ``ForwardOneToOneDescriptor`` instance.
""" """
def get_object(self, instance): def get_object(self, instance):
@ -303,7 +303,7 @@ class ReverseOneToOneDescriptor:
class Restaurant(Model): class Restaurant(Model):
place = OneToOneField(Place, related_name='restaurant') place = OneToOneField(Place, related_name='restaurant')
``place.restaurant`` is a ``ReverseOneToOneDescriptor`` instance. ``Place.restaurant`` is a ``ReverseOneToOneDescriptor`` instance.
""" """
def __init__(self, related): def __init__(self, related):
@ -466,7 +466,7 @@ class ReverseManyToOneDescriptor:
class Child(Model): class Child(Model):
parent = ForeignKey(Parent, related_name='children') parent = ForeignKey(Parent, related_name='children')
``parent.children`` is a ``ReverseManyToOneDescriptor`` instance. ``Parent.children`` is a ``ReverseManyToOneDescriptor`` instance.
Most of the implementation is delegated to a dynamically defined manager Most of the implementation is delegated to a dynamically defined manager
class built by ``create_forward_many_to_many_manager()`` defined below. class built by ``create_forward_many_to_many_manager()`` defined below.
@ -713,7 +713,7 @@ class ManyToManyDescriptor(ReverseManyToOneDescriptor):
class Pizza(Model): class Pizza(Model):
toppings = ManyToManyField(Topping, related_name='pizzas') toppings = ManyToManyField(Topping, related_name='pizzas')
``pizza.toppings`` and ``topping.pizzas`` are ``ManyToManyDescriptor`` ``Pizza.toppings`` and ``Topping.pizzas`` are ``ManyToManyDescriptor``
instances. instances.
Most of the implementation is delegated to a dynamically defined manager Most of the implementation is delegated to a dynamically defined manager