MCPcopy
hub / github.com/django/django / _check_unique_together

Method _check_unique_together

django/db/models/base.py:2156–2183  ·  view source on GitHub ↗

Check the value of "unique_together" option.

(cls)

Source from the content-addressed store, hash-verified

2154
2155 @classmethod
2156 def _check_unique_together(cls):
2157 """Check the value of "unique_together" option."""
2158 if not isinstance(cls._meta.unique_together, (tuple, list)):
2159 return [
2160 checks.Error(
2161 "'unique_together' must be a list or tuple.",
2162 obj=cls,
2163 id="models.E010",
2164 )
2165 ]
2166
2167 elif any(
2168 not isinstance(fields, (tuple, list))
2169 for fields in cls._meta.unique_together
2170 ):
2171 return [
2172 checks.Error(
2173 "All 'unique_together' elements must be lists or tuples.",
2174 obj=cls,
2175 id="models.E011",
2176 )
2177 ]
2178
2179 else:
2180 errors = []
2181 for fields in cls._meta.unique_together:
2182 errors.extend(cls._check_local_fields(fields, "unique_together"))
2183 return errors
2184
2185 @classmethod
2186 def _check_indexes(cls, databases):

Callers 1

checkMethod · 0.80

Calls 2

extendMethod · 0.80
_check_local_fieldsMethod · 0.80

Tested by

no test coverage detected