[Fixed]-Django Many To Many Insert Ordering

19👍

Django doesn’t guarantee to preserve the order of many-to-many relationships. If you need this, you should use a through table with an explicit ‘order’ field.

5👍

Thankfully, order can now be preserved in a ManyToMany relationship without the extra complexity of using a through model using sortedm2m which is a drop-in replacement for django’s own ManyToManyField.

https://github.com/gregmuellegger/django-sortedm2m

Leave a comment