#30395: ModelForm: allow to declaratively specify field classes corresponding to
model fields with choices
--------------------------------------+------------------------------------
     Reporter:  Quentin               |                    Owner:  nobody
         Type:  Cleanup/optimization  |                   Status:  new
    Component:  Documentation         |                  Version:  master
     Severity:  Normal                |               Resolution:
     Keywords:  ModelForm             |             Triage Stage:  Accepted
    Has patch:  0                     |      Needs documentation:  0
  Needs tests:  0                     |  Patch needs improvement:  0
Easy pickings:  0                     |                    UI/UX:  0
--------------------------------------+------------------------------------
Changes (by Carlton Gibson):

 * component:  Forms => Documentation
 * version:  2.2 => master
 * type:  New feature => Cleanup/optimization
 * stage:  Unreviewed => Accepted


Comment:

 Hi Quentin,

 Thanks for the report.

 Essentially, you've hit the limit of what's worth doing with `Meta`
 options vs just declaring the form fields by hand. There comes a point
 when the meta API just isn't any simpler...
 — I don't think there'd be any appetite for adding another meta option for
 this. "Just declare the `iso = SloppyIsoField(...)` directly" will be the
 advise. (Or use a custom model field class specifying it's
 `choices_form_class` in `formfield`...)

 I guess an addition to
 
[https://github.com/django/django/blob/ed3c59097a01ed3f32f8a8bed95307fb5c181251/docs/topics/forms/modelforms.txt#L497
 Overriding the default fields] section of the ModelForms docs would be OK,
 if you can come up with a suitable addition.

 Looking from the paragraph starting `Finally, if you want complete control
 over of a field ...`. A sentence or two added there may be appropriate.
 (Will accept on that basis.)

-- 
Ticket URL: <https://code.djangoproject.com/ticket/30395#comment:1>
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.7da46ae0dcace3f1185ff46114fcbbf4%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to