本文整理汇总了Python中django.db.models.options.normalize_together方法的典型用法代码示例。如果您正苦于以下问题:Python options.normalize_together方法的具体用法?Python options.normalize_together怎么用?Python options.normalize_together使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.db.models.options
的用法示例。
在下文中一共展示了options.normalize_together方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from django.db.models import options [as 别名]
# 或者: from django.db.models.options import normalize_together [as 别名]
def __init__(self, name, unique_together):
self.name = name
unique_together = normalize_together(unique_together)
self.unique_together = set(tuple(cons) for cons in unique_together)
示例2: contribute_to_class
# 需要导入模块: from django.db.models import options [as 别名]
# 或者: from django.db.models.options import normalize_together [as 别名]
def contribute_to_class(self, cls, *args, **kwargs):
super().contribute_to_class(cls, *args, **kwargs)
# Add any necessary unique_together index to the model
if self.unique_for_fields and self.unique_db_constraint:
# Alter only original_attr to fake being a declared unique_together
# Cannot modify cls._meta.unique_together as it breaks state consistency for migrations
ut = set((self.unique_together, )).union(normalize_together(cls._meta.original_attrs.get('unique_together')))
cls._meta.original_attrs['unique_together'] = ut
示例3: __init__
# 需要导入模块: from django.db.models import options [as 别名]
# 或者: from django.db.models.options import normalize_together [as 别名]
def __init__(self, name, unique_together):
unique_together = normalize_together(unique_together)
self.unique_together = {tuple(cons) for cons in unique_together}
super().__init__(name)
示例4: __init__
# 需要导入模块: from django.db.models import options [as 别名]
# 或者: from django.db.models.options import normalize_together [as 别名]
def __init__(self, name, unique_together):
unique_together = normalize_together(unique_together)
self.unique_together = set(tuple(cons) for cons in unique_together)
super(AlterUniqueTogether, self).__init__(name)