mirror of
https://github.com/django/django.git
synced 2024-12-22 17:16:24 +00:00
Refs #30397 -- Optimized interpolation of index and constraint names a bit.
This commit is contained in:
parent
c4df2a7776
commit
9e35c8b2e3
@ -203,10 +203,9 @@ class Options:
|
|||||||
self.unique_together = normalize_together(self.unique_together)
|
self.unique_together = normalize_together(self.unique_together)
|
||||||
# App label/class name interpolation for names of constraints and
|
# App label/class name interpolation for names of constraints and
|
||||||
# indexes.
|
# indexes.
|
||||||
if not getattr(cls._meta, "abstract", False):
|
if not self.abstract:
|
||||||
for attr_name in {"constraints", "indexes"}:
|
self.constraints = self._format_names_with_class(cls, self.constraints)
|
||||||
objs = getattr(self, attr_name, [])
|
self.indexes = self._format_names_with_class(cls, self.indexes)
|
||||||
setattr(self, attr_name, self._format_names_with_class(cls, objs))
|
|
||||||
|
|
||||||
# verbose_name_plural is a special case because it uses a 's'
|
# verbose_name_plural is a special case because it uses a 's'
|
||||||
# by default.
|
# by default.
|
||||||
@ -234,13 +233,14 @@ class Options:
|
|||||||
|
|
||||||
def _format_names_with_class(self, cls, objs):
|
def _format_names_with_class(self, cls, objs):
|
||||||
"""App label/class name interpolation for object names."""
|
"""App label/class name interpolation for object names."""
|
||||||
|
names = {
|
||||||
|
"app_label": cls._meta.app_label.lower(),
|
||||||
|
"class": cls.__name__.lower(),
|
||||||
|
}
|
||||||
new_objs = []
|
new_objs = []
|
||||||
for obj in objs:
|
for obj in objs:
|
||||||
obj = obj.clone()
|
obj = obj.clone()
|
||||||
obj.name = obj.name % {
|
obj.name = obj.name % names
|
||||||
"app_label": cls._meta.app_label.lower(),
|
|
||||||
"class": cls.__name__.lower(),
|
|
||||||
}
|
|
||||||
new_objs.append(obj)
|
new_objs.append(obj)
|
||||||
return new_objs
|
return new_objs
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user