diff options
| author | Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> | 2025-09-19 16:27:51 +0200 |
|---|---|---|
| committer | Natalia <124304+nessita@users.noreply.github.com> | 2025-10-13 14:54:20 -0300 |
| commit | 0fa339ce71bae6f9cebe341876f6aa41840ca2ff (patch) | |
| tree | 9c45f2ab02c3b8c685fb9cad8bd013793df77228 /django/db | |
| parent | 86e7406cfb839a6c5384e9f72a55ef78eccc9a3c (diff) | |
[6.0.x] Fixed #36611, Refs #36580 -- Added system check for multicolumn ForeignObject in Meta.indexes/constraints/unique_together.
ForeignObjects with multiple `from_fields` are not supported in these
options.
Co-authored-by: Jacob Walls <jacobtylerwalls@gmail.com>
Co-authored-by: Natalia <124304+nessita@users.noreply.github.com>
Backport of 5b51e6f759f2ba993219347435149173c756c478 from main.
Diffstat (limited to 'django/db')
| -rw-r--r-- | django/db/models/base.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/django/db/models/base.py b/django/db/models/base.py index 36b16c1132..d1321d6540 100644 --- a/django/db/models/base.py +++ b/django/db/models/base.py @@ -2220,6 +2220,20 @@ class Model(AltersData, metaclass=ModelBase): id="models.E048", ) ) + elif ( + isinstance(field.remote_field, ForeignObjectRel) + and field not in cls._meta.local_concrete_fields + and len(field.from_fields) > 1 + ): + errors.append( + checks.Error( + f"{option!r} refers to a ForeignObject {field_name!r} with " + "multiple 'from_fields', which is not supported for that " + "option.", + obj=cls, + id="models.E049", + ) + ) elif field not in cls._meta.local_fields: errors.append( checks.Error( |
