I have a UserForm class:
class UserForm(Form):
first_name = TextField(u\'First name\', [validators.Required()])
last_name = TextField(u\'Last name\', [va
I have combined two answers into following snippet:
def __iter__(self):
ordered_fields = collections.OrderedDict()
for name in getattr(self, 'field_order', []):
ordered_fields[name] = self._fields.pop(name)
ordered_fields.update(self._fields)
self._fields = ordered_fields
return super(BaseForm, self).__iter__()
It's iter on BaseForm that each of my form is child of. Basically everything that is defined in field_order goes in that order, rest of the fields are rendered as-is.