MCPcopy
hub / github.com/django/django / _post_clean

Method _post_clean

django/forms/models.py:479–513  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

477 self.add_error(None, errors)
478
479 def _post_clean(self):
480 opts = self._meta
481
482 exclude = self._get_validation_exclusions()
483
484 # Foreign Keys being used to represent inline relationships
485 # are excluded from basic field value validation. This is for two
486 # reasons: firstly, the value may not be supplied (#12507; the
487 # case of providing new values to the admin); secondly the
488 # object being referred to may not yet fully exist (#12749).
489 # However, these fields *must* be included in uniqueness checks,
490 # so this can't be part of _get_validation_exclusions().
491 for name, field in self.fields.items():
492 if isinstance(field, InlineForeignKeyField):
493 exclude.add(name)
494
495 try:
496 self.instance = construct_instance(
497 self, self.instance, opts.fields, opts.exclude
498 )
499 except ValidationError as e:
500 self._update_errors(e)
501
502 try:
503 self.instance.full_clean(
504 exclude=exclude, validate_unique=False, validate_constraints=False
505 )
506 except ValidationError as e:
507 self._update_errors(e)
508
509 # Validate uniqueness and constraints if needed.
510 if self._validate_unique:
511 self.validate_unique()
512 if self._validate_constraints:
513 self.validate_constraints()
514
515 def validate_unique(self):
516 """

Callers

nothing calls this directly

Calls 8

_update_errorsMethod · 0.95
validate_uniqueMethod · 0.95
validate_constraintsMethod · 0.95
construct_instanceFunction · 0.85
itemsMethod · 0.45
addMethod · 0.45
full_cleanMethod · 0.45

Tested by

no test coverage detected