def _constraint_names(self, model, column_names=None, unique=None,
                          primary_key=None, index=None, foreign_key=None,
                          check=None):
        """
        Returns all constraint names matching the columns and conditions
        """
        column_names = list(column_names) if column_names else None
        with self.connection.cursor() as cursor:
            constraints = get_constraints(cursor, model._meta.db_table)
        result = []
        for name, infodict in constraints.items():
            if column_names is None or column_names == infodict['columns']:
                if unique is not None and infodict['unique'] != unique:
                    continue
                if primary_key is not None and infodict['primary_key'] != primary_key:
                    continue
                if index is not None and infodict['index'] != index:
                    continue
                if check is not None and infodict['check'] != check:
                    continue
                if foreign_key is not None and not infodict['foreign_key']:
                    continue
                result.append(name)

        return result
def _constraint_names ( self , model , column_names = None , unique = None , primary_key = None , index = None , foreign_key = None , check = None ) : column_names = list ( column_names ) if column_names else None with self . connection . cursor ( ) as cursor : constraints = get_constraints ( cursor , model . _meta . db_table ) result = [ ] for name , infodict in constraints . items ( ) : if column_names is None or column_names == infodict [ 'columns' ] : if unique is not None and infodict [ 'unique' ] != unique : continue if primary_key is not None and infodict [ 'primary_key' ] != primary_key : continue if index is not None and infodict [ 'index' ] != index : continue if check is not None and infodict [ 'check' ] != check : continue if foreign_key is not None and not infodict [ 'foreign_key' ] : continue result . append ( name ) return result
Returns all constraint names matching the columns and conditions