Blogger Template by Blogcrowds.


Sometimes, we required to change the order of field rendering in modelform. We can override by adding "keyorder" in __init__ method.
class MyModel(ModelForm):
    def __init__(self, *args, **kwargs):
        super(MyModel, self).__init__(*args, **kwargs)
        self.fields.keyOrder = ['Field1', 'Field2','Field3', 'Field4']

0 Comments:

Post a Comment



Newer Post Older Post Home