[Django] #35103: UniqueConstraint message does not use violation_error_message

45 views
Skip to first unread message

Django

unread,
Jan 11, 2024, 9:43:12 AM1/11/24
to django-...@googlegroups.com
#35103: UniqueConstraint message does not use violation_error_message
-------------------------------------+-------------------------------------
Reporter: Gerben | Owner: nobody
Morsink |
Type: | Status: new
Cleanup/optimization |
Component: Database | Version: 4.1
layer (models, ORM) | Keywords: UniqueConstraint,
Severity: Normal | violation_error_message
Triage Stage: | Has patch: 1
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 1 |
-------------------------------------+-------------------------------------
Although this is documented, it is unexpected. Therefore I filed it as a
cleanup/optimization.

See https://forum.djangoproject.com/t/customizing-validationerror-message-
on-uniqueconstraint/25105 for a (possible) patch.

--
Ticket URL: <https://code.djangoproject.com/ticket/35103>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jan 11, 2024, 11:07:27 AM1/11/24
to django-...@googlegroups.com
#35103: UniqueConstraint message does not use violation_error_message
-------------------------------------+-------------------------------------
Reporter: Gerben Morsink | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Database layer | Version: 4.1
(models, ORM) |
Severity: Normal | Resolution:
Keywords: UniqueConstraint, | Triage Stage: Accepted
violation_error_message |
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* has_patch: 1 => 0
* ui_ux: 1 => 0
* stage: Unreviewed => Accepted


Comment:

While Simon did provide a draft patch on the forum, I'll uncheck "Has
patch" until there is a pull request to review.

--
Ticket URL: <https://code.djangoproject.com/ticket/35103#comment:1>

Django

unread,
Jan 11, 2024, 11:39:01 AM1/11/24
to django-...@googlegroups.com
#35103: UniqueConstraint message does not use violation_error_message
-------------------------------------+-------------------------------------
Reporter: Gerben Morsink | Owner: Gerben
Type: | Morsink
Cleanup/optimization | Status: assigned

Component: Database layer | Version: 4.1
(models, ORM) |
Severity: Normal | Resolution:
Keywords: UniqueConstraint, | Triage Stage: Accepted
violation_error_message |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Gerben Morsink):

* owner: nobody => Gerben Morsink
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/35103#comment:2>

Django

unread,
Jan 11, 2024, 11:48:14 AM1/11/24
to django-...@googlegroups.com
#35103: UniqueConstraint message does not use violation_error_message
-------------------------------------+-------------------------------------
Reporter: Gerben Morsink | Owner: Gerben
Type: | Morsink
Cleanup/optimization | Status: assigned
Component: Database layer | Version: 4.1
(models, ORM) |
Severity: Normal | Resolution:
Keywords: UniqueConstraint, | Triage Stage: Accepted
violation_error_message |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Gerben Morsink):

I created a patch in https://github.com/django/django/pull/17723

--
Ticket URL: <https://code.djangoproject.com/ticket/35103#comment:3>

Django

unread,
Jan 11, 2024, 11:48:43 AM1/11/24
to django-...@googlegroups.com
#35103: UniqueConstraint message does not use violation_error_message
-------------------------------------+-------------------------------------
Reporter: Gerben Morsink | Owner: Gerben
Type: | Morsink
Cleanup/optimization | Status: assigned
Component: Database layer | Version: 4.1
(models, ORM) |
Severity: Normal | Resolution:
Keywords: UniqueConstraint, | Triage Stage: Accepted
violation_error_message |
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Gerben Morsink):

* has_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/35103#comment:4>

Django

unread,
Jan 12, 2024, 2:08:29 AM1/12/24
to django-...@googlegroups.com
#35103: UniqueConstraint message does not use violation_error_message
-------------------------------------+-------------------------------------
Reporter: Gerben Morsink | Owner: Gerben
Type: | Morsink
Cleanup/optimization | Status: assigned
Component: Database layer | Version: 4.1
(models, ORM) |
Severity: Normal | Resolution:
Keywords: UniqueConstraint, | Triage Stage: Accepted
violation_error_message |
Has patch: 1 | Needs documentation: 1

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* needs_docs: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/35103#comment:5>

Django

unread,
May 30, 2024, 9:09:30 AM5/30/24
to django-...@googlegroups.com
#35103: UniqueConstraint message does not use violation_error_message
-------------------------------------+-------------------------------------
Reporter: Gerben Morsink | Owner: Gerben
Type: | Morsink
Cleanup/optimization | Status: assigned
Component: Database layer | Version: 4.1
(models, ORM) |
Severity: Normal | Resolution:
Keywords: UniqueConstraint, | Triage Stage: Accepted
violation_error_message |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Gerben Morsink):

* needs_docs: 1 => 0

--
Ticket URL: <https://code.djangoproject.com/ticket/35103#comment:6>

Django

unread,
May 31, 2024, 5:29:48 AM5/31/24
to django-...@googlegroups.com
#35103: UniqueConstraint message does not use violation_error_message
-------------------------------------+-------------------------------------
Reporter: Gerben Morsink | Owner: Gerben
Type: | Morsink
Cleanup/optimization | Status: assigned
Component: Database layer | Version: 4.1
(models, ORM) |
Severity: Normal | Resolution:
Keywords: UniqueConstraint, | Triage Stage: Accepted
violation_error_message |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):

* needs_better_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/35103#comment:7>

Django

unread,
Jun 4, 2024, 9:26:49 AM6/4/24
to django-...@googlegroups.com
#35103: UniqueConstraint message does not use violation_error_message
-------------------------------------+-------------------------------------
Reporter: Gerben Morsink | Owner: Gerben
Type: | Morsink
Cleanup/optimization | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: UniqueConstraint, | Triage Stage: Accepted
violation_error_message |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Gerben Morsink):

* needs_better_patch: 1 => 0
* version: 4.1 => dev

--
Ticket URL: <https://code.djangoproject.com/ticket/35103#comment:8>

Django

unread,
Jun 10, 2024, 2:13:49 AM6/10/24
to django-...@googlegroups.com
#35103: UniqueConstraint message does not use violation_error_message
-------------------------------------+-------------------------------------
Reporter: Gerben Morsink | Owner: Gerben
Type: | Morsink
Cleanup/optimization | Status: assigned
Component: Database layer | Version: 5.1
(models, ORM) |
Severity: Normal | Resolution:
Keywords: UniqueConstraint, | Triage Stage: Accepted
violation_error_message |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Gerben Morsink):

* version: dev => 5.1

--
Ticket URL: <https://code.djangoproject.com/ticket/35103#comment:9>

Django

unread,
Jun 12, 2024, 8:15:41 AM6/12/24
to django-...@googlegroups.com
#35103: UniqueConstraint message does not use violation_error_message
-------------------------------------+-------------------------------------
Reporter: Gerben Morsink | Owner: Gerben
Type: | Morsink
Cleanup/optimization | Status: assigned
Component: Database layer | Version: 5.1
(models, ORM) |
Severity: Normal | Resolution:
Keywords: UniqueConstraint, | Triage Stage: Accepted
violation_error_message |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):

* needs_better_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/35103#comment:10>

Django

unread,
Jun 12, 2024, 8:55:59 AM6/12/24
to django-...@googlegroups.com
#35103: UniqueConstraint message does not use violation_error_message
-------------------------------------+-------------------------------------
Reporter: Gerben Morsink | Owner: Gerben
Type: | Morsink
Cleanup/optimization | Status: assigned
Component: Database layer | Version: 5.1
(models, ORM) |
Severity: Normal | Resolution:
Keywords: UniqueConstraint, | Triage Stage: Accepted
violation_error_message |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Gerben Morsink):

* needs_better_patch: 1 => 0

--
Ticket URL: <https://code.djangoproject.com/ticket/35103#comment:11>

Django

unread,
Jun 17, 2024, 5:46:31 AM6/17/24
to django-...@googlegroups.com
#35103: UniqueConstraint message does not use violation_error_message
-------------------------------------+-------------------------------------
Reporter: Gerben Morsink | Owner: Gerben
Type: | Morsink
Cleanup/optimization | Status: assigned
Component: Database layer | Version: 5.1
(models, ORM) |
Severity: Normal | Resolution:
Keywords: UniqueConstraint, | Triage Stage: Accepted
violation_error_message |
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):

* needs_better_patch: 0 => 1
* needs_tests: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/35103#comment:12>

Django

unread,
Jun 18, 2024, 8:17:28 AM6/18/24
to django-...@googlegroups.com
#35103: UniqueConstraint message does not use violation_error_message
-------------------------------------+-------------------------------------
Reporter: Gerben Morsink | Owner: Gerben
Type: | Morsink
Cleanup/optimization | Status: assigned
Component: Database layer | Version: 5.1
(models, ORM) |
Severity: Normal | Resolution:
Keywords: UniqueConstraint, | Triage Stage: Accepted
violation_error_message |
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Gerben Morsink):

* needs_better_patch: 1 => 0

--
Ticket URL: <https://code.djangoproject.com/ticket/35103#comment:13>

Django

unread,
Sep 14, 2024, 9:36:01 AM9/14/24
to django-...@googlegroups.com
#35103: UniqueConstraint message does not use violation_error_message
-------------------------------------+-------------------------------------
Reporter: Gerben Morsink | Owner: Gerben
Type: | Morsink
Cleanup/optimization | Status: closed
Component: Database layer | Version: 5.1
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: UniqueConstraint, | Triage Stage: Accepted
violation_error_message |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Gerben Morsink):

* needs_tests: 1 => 0
* resolution: => fixed
* status: assigned => closed

--
Ticket URL: <https://code.djangoproject.com/ticket/35103#comment:14>

Django

unread,
Sep 14, 2024, 9:46:32 AM9/14/24
to django-...@googlegroups.com
#35103: UniqueConstraint message does not use violation_error_message
-------------------------------------+-------------------------------------
Reporter: Gerben Morsink | Owner: Gerben
Type: | Morsink
Cleanup/optimization | Status: new
Component: Database layer | Version: 5.1
(models, ORM) |
Severity: Normal | Resolution:
Keywords: UniqueConstraint, | Triage Stage: Accepted
violation_error_message |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Claude Paroz):

* resolution: fixed =>
* status: closed => new

Comment:

Please do not close a ticket before its patch is committed in the
repository. Unsetting the "Needs tests" flag should be enough to promote
the patch in the review queue again!
--
Ticket URL: <https://code.djangoproject.com/ticket/35103#comment:15>

Django

unread,
Sep 16, 2024, 6:14:33 AM9/16/24
to django-...@googlegroups.com
#35103: UniqueConstraint message does not use violation_error_message
-------------------------------------+-------------------------------------
Reporter: Gerben Morsink | Owner: Gerben
Type: | Morsink
Cleanup/optimization | Status: new
Component: Database layer | Version: 5.1
(models, ORM) |
Severity: Normal | Resolution:
Keywords: UniqueConstraint, | Triage Stage: Accepted
violation_error_message |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):

* easy: 1 => 0
* needs_better_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/35103#comment:16>

Django

unread,
Sep 17, 2024, 1:50:56 PM9/17/24
to django-...@googlegroups.com
#35103: UniqueConstraint message does not use violation_error_message
-------------------------------------+-------------------------------------
Reporter: Gerben Morsink | Owner: Gerben
Type: | Morsink
Cleanup/optimization | Status: new
Component: Database layer | Version: 5.1
(models, ORM) |
Severity: Normal | Resolution:
Keywords: UniqueConstraint, | Triage Stage: Accepted
violation_error_message |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Gerben Morsink):

Somehow a lot of seemingly unrelated tests are failing on my local
machine. It could have to do with
https://code.djangoproject.com/ticket/30581 being merged in between the
first release and the current release.

@Sarah Boyce: do you know why these lines were changed:
https://github.com/django/django/commit/13922580cccfb9ab2922ff4943dd39da56dfbd8c
?
--
Ticket URL: <https://code.djangoproject.com/ticket/35103#comment:17>

Django

unread,
Oct 10, 2024, 3:19:10 AM10/10/24
to django-...@googlegroups.com
#35103: UniqueConstraint message does not use violation_error_message
-------------------------------------+-------------------------------------
Reporter: Gerben Morsink | Owner: Gerben
Type: | Morsink
Cleanup/optimization | Status: new
Component: Database layer | Version: 5.1
(models, ORM) |
Severity: Normal | Resolution:
Keywords: UniqueConstraint, | Triage Stage: Ready for
violation_error_message | checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):

* needs_better_patch: 1 => 0
* stage: Accepted => Ready for checkin

--
Ticket URL: <https://code.djangoproject.com/ticket/35103#comment:18>

Django

unread,
Oct 10, 2024, 3:20:50 AM10/10/24
to django-...@googlegroups.com
#35103: UniqueConstraint message does not use violation_error_message
-------------------------------------+-------------------------------------
Reporter: Gerben Morsink | Owner: Gerben
Type: | Morsink
Cleanup/optimization | Status: closed
Component: Database layer | Version: 5.1
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: UniqueConstraint, | Triage Stage: Ready for
violation_error_message | checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce <42296566+sarahboyce@…>):

* resolution: => fixed
* status: new => closed

Comment:

In [changeset:"e970bb7ca71c00594b42a024a15a8ac007cc2c7a" e970bb7]:
{{{#!CommitTicketReference repository=""
revision="e970bb7ca71c00594b42a024a15a8ac007cc2c7a"
Fixed #35103 -- Used provided error code and message when fields is set
without a condition on UniqueConstraint.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/35103#comment:19>

Django

unread,
Sep 1, 2025, 3:55:30 PMSep 1
to django-...@googlegroups.com
#35103: UniqueConstraint message does not use violation_error_message
-------------------------------------+-------------------------------------
Reporter: Gerben Morsink | Owner: Gerben
Type: | Morsink
Cleanup/optimization | Status: closed
Component: Database layer | Version: 5.1
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: UniqueConstraint, | Triage Stage: Ready for
violation_error_message | checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Brendan):

I think this is still perhaps not working as intended, in particular when
using expressions. We can see with the simple case:

{{{
from django.db import models

class MyModel(models.Model)
name = models.CharField()

class Meta:
constraints = (
models.UniqueConstraint(
Lower("name"),
name="unique_supplier_name",
violation_error_message="test"
),
)
}}}

If for some reason it should be obvious and expected that
`violation_error_message` should not apply when using expressions, I think
we could perhaps clean up the docs to clarify this (and maybe why).
--
Ticket URL: <https://code.djangoproject.com/ticket/35103#comment:20>
Reply all
Reply to author
Forward
0 new messages