diff options
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/ref/models/fields.txt | 29 | ||||
| -rw-r--r-- | docs/releases/1.9.3.txt | 4 |
2 files changed, 33 insertions, 0 deletions
diff --git a/docs/ref/models/fields.txt b/docs/ref/models/fields.txt index d8d047e3c9..20c50a0b12 100644 --- a/docs/ref/models/fields.txt +++ b/docs/ref/models/fields.txt @@ -1155,6 +1155,35 @@ you can use the name of the model, rather than the model object itself:: # ... pass +Relationships defined this way on :ref:`abstract models +<abstract-base-classes>` are resolved when the model is subclassed as a +concrete model and are not relative to the abstract model's ``app_label``: + +.. snippet:: + :filename: products/models.py + + from django.db import models + + class AbstractCar(models.Model): + manufacturer = models.ForeignKey('Manufacturer', on_delete=models.CASCADE) + + class Meta: + abstract = True + +.. snippet:: + :filename: production/models.py + + from django.db import models + from products.models import AbstractCar + + class Manufacturer(models.Model): + pass + + class Car(AbstractCar): + pass + + # Car.manufacturer will point to `production.Manufacturer` here. + To refer to models defined in another application, you can explicitly specify a model with the full application label. For example, if the ``Manufacturer`` model above is defined in another application called ``production``, you'd diff --git a/docs/releases/1.9.3.txt b/docs/releases/1.9.3.txt index e0447d2afe..e94d555ec0 100644 --- a/docs/releases/1.9.3.txt +++ b/docs/releases/1.9.3.txt @@ -52,3 +52,7 @@ Bugfixes * Prevented ``ContentTypeManager`` instances from sharing their cache (:ticket:`26286`). + +* Reverted a change in Django 1.9.2 (:ticket:`25858`) that prevented relative + lazy relationships defined on abstract models to be resolved according to + their concrete model's ``app_label`` (:ticket:`26186`). |
