mirror of
https://github.com/django/django.git
synced 2025-06-05 11:39:13 +00:00
Refs #30397 -- Optimized interpolation of index and constraint names a bit more.
This commit is contained in:
parent
549320946d
commit
1669e54965
@ -204,8 +204,8 @@ class Options:
|
|||||||
# App label/class name interpolation for names of constraints and
|
# App label/class name interpolation for names of constraints and
|
||||||
# indexes.
|
# indexes.
|
||||||
if not self.abstract:
|
if not self.abstract:
|
||||||
self.constraints = self._format_names_with_class(cls, self.constraints)
|
self.constraints = self._format_names(self.constraints)
|
||||||
self.indexes = self._format_names_with_class(cls, self.indexes)
|
self.indexes = self._format_names(self.indexes)
|
||||||
|
|
||||||
# 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.
|
||||||
@ -231,16 +231,13 @@ class Options:
|
|||||||
self.db_table, connection.ops.max_name_length()
|
self.db_table, connection.ops.max_name_length()
|
||||||
)
|
)
|
||||||
|
|
||||||
def _format_names_with_class(self, cls, objs):
|
def _format_names(self, objs):
|
||||||
"""App label/class name interpolation for object names."""
|
"""App label/class name interpolation for object names."""
|
||||||
names = {
|
names = {"app_label": self.app_label.lower(), "class": self.model_name}
|
||||||
"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 % names
|
obj.name %= names
|
||||||
new_objs.append(obj)
|
new_objs.append(obj)
|
||||||
return new_objs
|
return new_objs
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user