1
0
mirror of https://github.com/django/django.git synced 2025-11-07 07:15:35 +00:00

Fixed #34338 -- Allowed customizing code of ValidationError in BaseConstraint and subclasses.

This commit is contained in:
Xavier Fernandez
2023-02-14 21:06:45 +01:00
committed by Mariusz Felisiak
parent 51c9bb7cd1
commit 5b3d3e400a
7 changed files with 268 additions and 23 deletions

View File

@@ -78,7 +78,10 @@ Minor features
:mod:`django.contrib.postgres`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* ...
* The new :attr:`~.ExclusionConstraint.violation_error_code` attribute of
:class:`~django.contrib.postgres.constraints.ExclusionConstraint` allows
customizing the ``code`` of ``ValidationError`` raised during
:ref:`model validation <validating-objects>`.
:mod:`django.contrib.redirects`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -182,6 +185,13 @@ Models
and :meth:`.QuerySet.aupdate_or_create` methods allows specifying a different
field values for the create operation.
* The new ``violation_error_code`` attribute of
:class:`~django.db.models.BaseConstraint`,
:class:`~django.db.models.CheckConstraint`, and
:class:`~django.db.models.UniqueConstraint` allows customizing the ``code``
of ``ValidationError`` raised during
:ref:`model validation <validating-objects>`.
Requests and Responses
~~~~~~~~~~~~~~~~~~~~~~