def drop_constraints_and_indexes(self):
"""
Temporarily drop constraints and indexes on the model and its fields.
"""
with connection.schema_editor() as schema_editor:
schema_editor.alter_unique_together(
self.model,
self.model._meta.unique_together,
(),
)
schema_editor.alter_index_together(
self.model,
self.model._meta.index_together,
(),
)
for field in self.model.objects.constrained_fields:
field_copy = field.__copy__()
field_copy.db_constraint = False
schema_editor.alter_field(
self.model, field, field_copy
)
for field in self.model.objects.indexed_fields:
field_copy = field.__copy__()
field_copy.db_index = False
schema_editor.alter_field(
self.model, field, field_copy
)
managers.py 文件源码
python
阅读 28
收藏 0
点赞 0
评论 0
评论列表
文章目录