How can I access the ordered list of model fields? Because model_instance._meta.fields returns fields without m2m, but in admin view the fields order exactly same as they are defined in class.
(like edit form on admin site) ?
How can I access the ordered list of model fields? Because model_instance._meta.fields returns fields
Share
Try
If M2M fields are defined after normal fields, you could use
fields + many_to_manydirectly since both of them are already in the declaration ordering.update
If you prefer to use
operator.attrgetter()instead oflambda, it’s OK, the performance difference is trivial. Butattrgetteris not guranteed to be faster: