MCPcopy
hub / github.com/django/django / validate_unique

Method validate_unique

django/db/models/base.py:1450–1464  ·  view source on GitHub ↗

Check unique constraints on the model and raise ValidationError if any failed.

(self, exclude=None)

Source from the content-addressed store, hash-verified

1448 pass
1449
1450 def validate_unique(self, exclude=None):
1451 """
1452 Check unique constraints on the model and raise ValidationError if any
1453 failed.
1454 """
1455 unique_checks, date_checks = self._get_unique_checks(exclude=exclude)
1456
1457 errors = self._perform_unique_checks(unique_checks)
1458 date_errors = self._perform_date_checks(date_checks)
1459
1460 for k, v in date_errors.items():
1461 errors.setdefault(k, []).extend(v)
1462
1463 if errors:
1464 raise ValidationError(errors)
1465
1466 def _get_unique_checks(self, exclude=None, include_meta_constraints=False):
1467 """

Callers 7

full_cleanMethod · 0.95
test_unique_domainMethod · 0.45
test_validate_uniqueMethod · 0.45
test_geography_uniqueMethod · 0.45
test_uniqueMethod · 0.45
test_unique_togetherMethod · 0.45
test_pk_validationMethod · 0.45

Calls 7

_get_unique_checksMethod · 0.95
_perform_date_checksMethod · 0.95
ValidationErrorClass · 0.90
extendMethod · 0.80
itemsMethod · 0.45
setdefaultMethod · 0.45

Tested by 6

test_unique_domainMethod · 0.36
test_validate_uniqueMethod · 0.36
test_geography_uniqueMethod · 0.36
test_uniqueMethod · 0.36
test_unique_togetherMethod · 0.36
test_pk_validationMethod · 0.36