diff options
| author | hui shang <shangdahao@gmail.com> | 2017-12-28 07:56:24 +0800 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2017-12-27 18:56:24 -0500 |
| commit | f1aa58479cdc6051dd2e97feca2d584c43aee1e7 (patch) | |
| tree | 1f59109f6c02462716ae76bb45c26548c918164b /django | |
| parent | 1d00923848d504c6132019492b8d5a6cdf8261db (diff) | |
Fixed #28714 -- Added system checks for invalid model field names in Meta.indexes.
Thanks Gabriel for the report and Adam Johnson for the review.
Diffstat (limited to 'django')
| -rw-r--r-- | django/db/models/base.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/django/db/models/base.py b/django/db/models/base.py index 36be70beb5..2588ee3ff6 100644 --- a/django/db/models/base.py +++ b/django/db/models/base.py @@ -1203,6 +1203,7 @@ class Model(metaclass=ModelBase): errors += [ *cls._check_index_together(), *cls._check_unique_together(), + *cls._check_indexes(), *cls._check_ordering(), ] @@ -1475,6 +1476,12 @@ class Model(metaclass=ModelBase): return errors @classmethod + def _check_indexes(cls): + """Check the fields of indexes.""" + fields = [field for index in cls._meta.indexes for field, _ in index.fields_orders] + return cls._check_local_fields(fields, 'indexes') + + @classmethod def _check_local_fields(cls, fields, option): from django.db import models |
