Skip to content

Commit

Permalink
getattr code
Browse files Browse the repository at this point in the history
  • Loading branch information
bukowa committed Feb 7, 2023
1 parent f583056 commit 9454b2e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion django/db/models/base.py
Expand Up @@ -1444,7 +1444,7 @@ def validate_constraints(self, exclude=None):
try:
constraint.validate(model_class, self, exclude=exclude, using=using)
except ValidationError as e:
if e.code == "unique" and len(constraint.fields) == 1:
if getattr(e, 'code', None) == "unique" and len(constraint.fields) == 1:
errors.setdefault(constraint.fields[0], []).append(e)
else:
errors = e.update_error_dict(errors)
Expand Down

0 comments on commit 9454b2e

Please sign in to comment.