django-sortedm2m
A transparent sorted ManyToMany field for django.
django-sortedm2m Explanation
Django is a web framework that lets you build applications with databases. One common database problem is connecting two types of things that have a many-to-many relationship — for example, a gallery can contain many photos, and a photo can appear in many galleries. Django has a built-in tool for this called ManyToManyField, but it has a limitation: it doesn't remember the order in which you added the photos to a gallery.
This package solves that problem by providing a replacement field called SortedManyToManyField. It works exactly like Django's normal many-to-many field, except it keeps track of the order. So when you add photos to a gallery one by one, the gallery remembers that order. When you later retrieve the photos, they come back in the same sequence you added them, not in some random order.
Using it is straightforward — you just swap out the field name in your code. Instead of writing photos = ManyToManyField(Photo), you write photos = SortedManyToManyField(Photo). The rest of your code works the same way, and the ordering happens automatically behind the scenes.
The package also includes nice admin interface features. If you're using Django's admin panel to manage your galleries, you get a drag-and-drop widget to reorder photos visually. Alternatively, if you prefer working with raw IDs, you can enter photo IDs in a text box and the order you type them in becomes the gallery's order.
In short: this is a small, focused tool for anyone building a Django site where the order of related items matters — like photo galleries, playlists, recommended products, or any similar situation where you need both multiple connections and a specific sequence.