Python django.db.models.options.normalize_together() Examples

The following are 13 code examples of django.db.models.options.normalize_together(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module django.db.models.options , or try the search function .
Example #1
Source File: models.py    From GTDWeb with GNU General Public License v2.0 5 votes vote down vote up
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) 
Example #2
Source File: models.py    From GTDWeb with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, name, index_together):
        self.name = name
        index_together = normalize_together(index_together)
        self.index_together = set(tuple(cons) for cons in index_together) 
Example #3
Source File: mixins.py    From django-more with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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 
Example #4
Source File: models.py    From bioforum with MIT License 5 votes vote down vote up
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) 
Example #5
Source File: models.py    From bioforum with MIT License 5 votes vote down vote up
def __init__(self, name, index_together):
        index_together = normalize_together(index_together)
        self.index_together = {tuple(cons) for cons in index_together}
        super().__init__(name) 
Example #6
Source File: models.py    From Hands-On-Application-Development-with-PyCharm with MIT License 5 votes vote down vote up
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) 
Example #7
Source File: models.py    From Hands-On-Application-Development-with-PyCharm with MIT License 5 votes vote down vote up
def __init__(self, name, index_together):
        index_together = normalize_together(index_together)
        self.index_together = {tuple(cons) for cons in index_together}
        super().__init__(name) 
Example #8
Source File: models.py    From python with Apache License 2.0 5 votes vote down vote up
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) 
Example #9
Source File: models.py    From python with Apache License 2.0 5 votes vote down vote up
def __init__(self, name, index_together):
        index_together = normalize_together(index_together)
        self.index_together = set(tuple(cons) for cons in index_together)
        super(AlterIndexTogether, self).__init__(name) 
Example #10
Source File: models.py    From openhgsenti with Apache License 2.0 5 votes vote down vote up
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) 
Example #11
Source File: models.py    From openhgsenti with Apache License 2.0 5 votes vote down vote up
def __init__(self, name, index_together):
        self.name = name
        index_together = normalize_together(index_together)
        self.index_together = set(tuple(cons) for cons in index_together) 
Example #12
Source File: models.py    From python2017 with MIT License 5 votes vote down vote up
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) 
Example #13
Source File: models.py    From python2017 with MIT License 5 votes vote down vote up
def __init__(self, name, index_together):
        index_together = normalize_together(index_together)
        self.index_together = set(tuple(cons) for cons in index_together)
        super(AlterIndexTogether, self).__init__(name)