#5986: Easy way to customize ordering of fields on forms that use inheritance
-------------------------------------+-------------------------------------
     Reporter:  emes                 |                    Owner:  nobody
         Type:  New feature          |                   Status:  new
    Component:  Forms                |                  Version:  master
     Severity:  Normal               |               Resolution:
     Keywords:  field order weight   |             Triage Stage:  Accepted
  form newforms                      |      Needs documentation:  0
    Has patch:  0                    |  Patch needs improvement:  0
  Needs tests:  0                    |                    UI/UX:  0
Easy pickings:  0                    |
-------------------------------------+-------------------------------------
Changes (by timgraham):

 * needs_docs:  1 => 0
 * has_patch:  1 => 0
 * stage:  Unreviewed => Accepted


Comment:

 Pre-Django 1.7, the following worked, but relied on internal
 implementation details (that `self.fields` was `SortedDict`; now it's
 `OrderedDict`):
 {{{
 class EditForm(forms.Form):
     summary = forms.CharField()
     description = forms.CharField(widget=forms.TextArea)


 class CreateForm(EditForm):
     name = forms.CharField()

     def __init__(self, *args, **kwargs):
         super(CreateForm, self).__init__(*args, **kwargs)
         self.fields.keyOrder = ['name', 'summary', 'description']
 }}}
 Adding an official API for making ordering easier on forms that use
 inheritance seems reasonable. I'm not sure if recommending `base_fields`
 is the best approach as that's not public API as of now.

--
Ticket URL: <https://code.djangoproject.com/ticket/5986#comment:25>
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/062.30ff7cb12c7d080f0543d776c217f6a2%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to