Login

Tag "workaround"

Snippet List

Reorder fields directly in the ModelForm

Sometimes the order of the fields you get from a model needs to be adjusted when displaying its modelform. If it's just a few fields you can do it in the template, but what if you want to iterate over the form? The fields are stored in a SortedDict, so you can change the order in the __init__ of the form. A bit clunky, yes.

  • newforms
  • modelform
  • field-order
  • workaround
Read More
Author: HM
  • 6
  • 5

2 snippets posted so far.