當前位置: 首頁>>代碼示例>>Python>>正文


Python options.normalize_together方法代碼示例

本文整理匯總了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) 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:6,代碼來源:models.py

示例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 
開發者ID:ashleywaite,項目名稱:django-more,代碼行數:11,代碼來源:mixins.py

示例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) 
開發者ID:reBiocoder,項目名稱:bioforum,代碼行數:6,代碼來源:models.py

示例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) 
開發者ID:Yeah-Kun,項目名稱:python,代碼行數:6,代碼來源:models.py


注:本文中的django.db.models.options.normalize_together方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。