diff options
| author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2017-09-17 08:26:18 +0200 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2017-09-18 14:06:00 -0400 |
| commit | fb02ebe889eee292144f9157ed4ddcdcc139eba9 (patch) | |
| tree | a4fda2469ea51439add018a530eeab0a1611e0b9 /django | |
| parent | 94cd8efc50c717cd00244f4b2233f971a53b205e (diff) | |
Fixed #28597 -- Fixed crash with the name of a model's autogenerated primary key in an Index's fields.
Diffstat (limited to 'django')
| -rw-r--r-- | django/db/models/base.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/django/db/models/base.py b/django/db/models/base.py index 34e0d65980..dc59143eb5 100644 --- a/django/db/models/base.py +++ b/django/db/models/base.py @@ -296,12 +296,6 @@ class ModelBase(type): # Copy indexes so that index names are unique when models extend an # abstract model. new_class._meta.indexes = [copy.deepcopy(idx) for idx in new_class._meta.indexes] - # Set the name of _meta.indexes. This can't be done in - # Options.contribute_to_class() because fields haven't been added to - # the model at that point. - for index in new_class._meta.indexes: - if not index.name: - index.set_name_with_model(new_class) if abstract: # Abstract base models can't be instantiated and don't appear in @@ -359,6 +353,13 @@ class ModelBase(type): manager.auto_created = True cls.add_to_class('objects', manager) + # Set the name of _meta.indexes. This can't be done in + # Options.contribute_to_class() because fields haven't been added to + # the model at that point. + for index in cls._meta.indexes: + if not index.name: + index.set_name_with_model(cls) + class_prepared.send(sender=cls) @property |
