#31207: Broken foreing key reference with multi-table inheritance (PostgreSQL,
Django 3.0)
-------------------------------------+-------------------------------------
Reporter: un.def | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 3.0
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by un.def):
I totally agree that
> to_field should only be allowed to point a local fields
but in this case the behavior should be consistent. As I mentioned before
(**Note** section), I still can create “''non-local''” foreign key
reference (i.e. reference pointing to child model but to field from parent
model) with `CreateModel(fields=...)` (but not with `AddField(...)`).
So, my suggestions are as follows:
* completely forbid `to_field` that points to field of parent ''non-
abstract'' model;
* add a note to documentation about changed behavior (previous behavior
was not documented but can be used in the wild; actually, I have run into
this problem in a legacy project).
--
Ticket URL: <https://code.djangoproject.com/ticket/31207#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/064.9643f2e0773b0b20e1bcd69c5818d9cf%40djangoproject.com.