#32347: ModelChoiceField does not provide value of invalid choice when raising
ValidationError
------------------------------+----------------------------------------
     Reporter:  Aaron Wiegel  |                    Owner:  Aaron Wiegel
         Type:  Bug           |                   Status:  closed
    Component:  Forms         |                  Version:  3.1
     Severity:  Normal        |               Resolution:  wontfix
     Keywords:                |             Triage Stage:  Unreviewed
    Has patch:  0             |      Needs documentation:  0
  Needs tests:  0             |  Patch needs improvement:  0
Easy pickings:  1             |                    UI/UX:  0
------------------------------+----------------------------------------

Comment (by Aaron Wiegel):

 Replying to [comment:3 Carlton Gibson]:
 > This message has been the same literally forever
 b2b6fc8e3c78671c8b6af2709358c3213c84d119.
 >
 >
 
[https://github.com/django/django/blob/75182a800a621b7a5b2c0a1f39a56e753b9a58ca/django/forms/fields.py#L802-L810
 Given that ChoiceField passes the value when raising the error], if you
 set [https://docs.djangoproject.com/en/3.1/ref/forms/fields/#error-
 messages error_messages] you should be able to get the result you want.

 That is `ChoiceField`. `ModelChoiceField` (does not pass the
 
value)[https://github.com/django/django/blob/a948d9df394aafded78d72b1daa785a0abfeab48/django/forms/models.py#L1287]
 to the validation error. So, when the invalid value error is raised, you
 can't display the offending value even if you override the defaults.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32347#comment:4>
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.9e2b09c7a18388556dcc22ebad3c4f83%40djangoproject.com.

Reply via email to