summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
Diffstat (limited to 'django')
-rw-r--r--django/db/models/base.py13
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