#33399: Overriding Choices for a field in the Form not working when using
ModelForm.
-------------------------------+--------------------------------------
     Reporter:  Swaroop P      |                    Owner:  nobody
         Type:  Uncategorized  |                   Status:  closed
    Component:  Forms          |                  Version:  3.0
     Severity:  Normal         |               Resolution:  invalid
     Keywords:  modelform      |             Triage Stage:  Unreviewed
    Has patch:  0              |      Needs documentation:  0
  Needs tests:  0              |  Patch needs improvement:  0
Easy pickings:  0              |                    UI/UX:  0
-------------------------------+--------------------------------------
Changes (by Mariusz Felisiak):

 * status:  new => closed
 * version:  3.2 => 3.0
 * resolution:   => invalid


Comment:

 Thanks for the report, it was changed in
 16a5a2a2c8d8dbf9cc3e033dd84b986bcaadb963, however it's
 
[https://docs.djangoproject.com/en/4.0/ref/models/fields/#django.db.models.Field.choices
 documented] that:

 > ''For **each model field that has `choices` set**, Django will add a
 method to retrieve the human-readable name for the field’s current value.
 See `get_FOO_display()` in the database API documentation.''
 >
 > ''Note that choices can be any sequence object – not necessarily a list
 or tuple. This lets you construct choices dynamically. But if you find
 yourself hacking choices to be dynamic, you’re probably better off using a
 proper database table with a `ForeignKey`. `choices` **is meant for static
 data that doesn’t change much, if ever.'**'

 `choices=[]` means that it's set, if you want to get the previous behavior
 without any validation you shouldn't define `choices` on a model field, or
 set `choices=None`.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33399#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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/069.1c413425e09a5747404b76a80c26dd14%40djangoproject.com.

Reply via email to