Handle constraints error messages defined in model #9348
Unanswered
sevdog
asked this question in
Ideas & Suggestions
Replies: 2 comments
-
Would you be able to add interlinking to the above so that we can compare & contrast? (There was an attempt made to resolve this in #8863, which was reverted in #9330.) |
Beta Was this translation helpful? Give feedback.
0 replies
-
This is the "format" section in DRF django-rest-framework/rest_framework/validators.py Lines 175 to 178 in 085b7e1 This is the "format" section of django There is also a big difference in which elements are used for formatting:
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In django 4.1 it was added to constraints a
violation_error_message
attribute which is used by django validation to provide an appropriate error message when the constraint is not respected.Currently this field is not used by DRF and was not covered in #7438, which was created before this feature was introduced and therefore did not addressed it later.
It would be very useful to support using the
violation_error_message
as defaultmessage
forUniqueTogetherValidator
automatically created from model's constraints.However there is an issue in this: because django uses
%
formatting while the DRF uses.format
and this makes the two messages formats incompatible. Thus a solution should be found without introducing some kind of regression for "unique togheter" validation.This feature is important because currently there is no easy way to customize the error message of a unique validator derived from a unique constraint.
Beta Was this translation helpful? Give feedback.
All reactions