In Django 1.9, they add a new argument to the Form class. Now you can change the order by specifying field_order for example, adding two fields to the user's application form:
class SignupFormExtra(SignupForm): """ A form to demonstrate how to add extra fields to the signup form, in this case adding the first and last name. """ first_name = forms.CharField(label=_(u'First name'), max_length=30, required=False) last_name = forms.CharField(label=_(u'Last name'), max_length=30, required=False) field_order=['first_name','last_name']
You can use it in any form inheriting from the Form class.
By default, Form.field_order = None, which preserves the order in which you define the fields in your form class. If field_order is a list of field names, the fields are ordered as indicated in the list, and the remaining fields are added in the default order.
Algor
source share