diff options
| author | Simon Charette <charette.s@gmail.com> | 2016-02-22 16:05:47 -0500 |
|---|---|---|
| committer | Simon Charette <charette.s@gmail.com> | 2016-02-29 22:13:54 -0500 |
| commit | 48cf7516409c668bf11e24e6b7cd8eaea13ae3b8 (patch) | |
| tree | 5b4c48da5e86dcf2cf6412fde0ce67dff01147fa /docs | |
| parent | e9234569f69e0afcc97b3b1ff5293bad1678a076 (diff) | |
[1.9.x] Fixed #26186 -- Documented how app relative relationships of abstract models behave.
This partially reverts commit bc7d201bdbaeac14a49f51a9ef292d6312b4c45e.
Thanks Tim for the review.
Refs #25858.
Backport of 0223e213dd690b6b6e0669f836a20efb10998c83 from master
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`). |
