本文整理匯總了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)