#33591: Incorrect validation message
-------------------------------------+-------------------------------------
     Reporter:  Maria Sorokina       |                    Owner:  nobody
         Type:  Bug                  |                   Status:  closed
    Component:  Forms                |                  Version:  4.0
     Severity:  Normal               |               Resolution:  invalid
     Keywords:  ValidationError,     |             Triage Stage:
  validation, message                |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Maria Sorokina):

 Replying to [comment:1 Mariusz Felisiak]:
 > Validation error messages defined at the model level are always override
 with those defined on the form fields, see
 [https://docs.djangoproject.com/en/stable/topics/forms/modelforms
 /#considerations-regarding-model-s-error-messages docs].
 `forms.IntegerField` has already defined an
 
[https://github.com/django/django/blob/b07ee98b27e58992fdc10fec0ec67e68ae1d272d/django/forms/fields.py#L297-L299
 invalid] error message.

 Thank you for your reply! Even in spite of your comment a couple of things
 still confuse me:

 1. I understood the part about overriding model validation with form
 validation. What I cannot understand is why would I get an error message
 "Enter a whole number" when I enter the whole number. I understand that
 this is a default message but it doesn't make much sense to me.

 2. I've read some
 [https://docs.djangoproject.com/en/4.0/ref/forms/validation/ docs] before
 coming here. There are some good practices regarding ''code'' parameter on
 this web page. So I made a conclusion that it's better to give this
 parameter to the ''ValidationError'' function, but I didn't find any
 information in the docs about how I should use this argument properly, so
 I just followed the examples which led me to the described situation. I
 would be grateful if you could provide more information about the
 parameter in the docs.

 I am very sorry if I wasted your time, I just want to be sure that other
 users won't be confused as I am now.
 Best wishes.

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

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107017fabad1a6f-18b64b0c-22b4-4886-b838-0d029eb52c1e-000000%40eu-central-1.amazonses.com.

Reply via email to