$npx skillfedfor your agent

django-sortedm2m

Drop-in replacement for Django's many to many field with sorted relations.

Worth itPyPI Dynamic ContentReleased Aug 2024389.3K downloads / moBSDPure Python

Decision gist · record as of 2026-08-14

pure-Python wheel — django_sortedm2m-4.0.0-py2.py3-none-any.whl
v4.0.0 · released 2024-08-11

Yes. This is a well-maintained, production-stable package with no known vulnerabilities, low install friction, and a permissive license. It solves a real Django limitation (unordered many-to-many relations) with a straightforward drop-in replacement. Use it whenever you need to preserve relation order in a Django model.AI-flagged interpretation of the facts on this page — verify before relying

Before you install

  • Requires Django 4.2, 5.0, or 5.1; add 'sortedm2m' to INSTALLED_APPS to use the admin widget and its CSS/JS assets.
  • Low friction installation with no runtime dependencies.
  • Actively maintained with recent releases supporting Django 5.1 and Python 3.7–3.12; repository shows steady activity and 525 stars.

License · maintenance · safety

BSD (permissive) — BSD license is permissive; you can use, modify, and distribute this package with minimal restrictions, provided you include the license notice.

last release 2024-08-11 (733 days) · last repo commit 2026-08-10 · 525 stars

0 known vulnerabilities (OSV.dev, 2026-08-14) · 389,270 downloads/mo, #7,032 on PyPI

Verify before relying

pip install django-sortedm2m

from sortedm2m.fields import SortedManyToManyField
from django.db import models

class Gallery(models.Model):
    photos = SortedManyToManyField('Photo')

gallery = Gallery.objects.create(name='My Gallery')
for photo in Photo.objects.order_by('name'):
    gallery.photos.add(photo)  # order is preserved
  • Whether the package supports Django versions earlier than 4.2 (version 4.0.0 dropped support for outdated versions, but exact cutoff is unclear).
  • Performance characteristics when managing large numbers of related objects or complex sort operations.
Same gist for agents: .md · .json

What it is and what it does

django-sortedm2m is a Django field that works exactly like the built-in ManyToManyField but remembers the order in which you add related objects. Instead of getting relations back in an arbitrary order, you get them in the order you added them, with the sort position stored in the database. This is useful for galleries, playlists, or any scenario where the sequence of related items matters.

The package provides a SortedManyToManyField class you drop into your models in place of ManyToManyField, and an optional admin widget that lets you reorder relations by dragging and dropping. It handles database migrations automatically and supports Django 4.2 through 5.1 on Python 3.7–3.12. There are no runtime dependencies beyond Django itself.

Use it for

  • Gallery or portfolio models where photos must appear in a specific sequence chosen by the user.
  • Playlist or media collection models where track or item order is part of the data model.
  • Admin interfaces where users need to reorder many-to-many relationships via drag-and-drop.
  • Legacy database integration where you need to rename the sort field to match existing schema.
  • Custom through models where you want to add a __str__ method to improve admin display of relationships.

Worth the install?

AI-flagged interpretation of the facts on this page. Verify before relying on it.

Worth it

Yes.

This is a well-maintained, production-stable package with no known vulnerabilities, low install friction, and a permissive license. It solves a real Django limitation (unordered many-to-many relations) with a straightforward drop-in replacement. Use it whenever you need to preserve relation order in a Django model.

Install

django-sortedm2m on PyPI

Before you install

Low friction installation with no runtime dependencies. Actively maintained with recent releases supporting Django 5.1 and Python 3.7–3.12; repository shows steady activity and 525 stars.

Requires Django 4.2, 5.0, or 5.1; add 'sortedm2m' to INSTALLED_APPS to use the admin widget and its CSS/JS assets.

License in practice

BSD license is permissive; you can use, modify, and distribute this package with minimal restrictions, provided you include the license notice.

Quickstart

pip install django-sortedm2m

from sortedm2m.fields import SortedManyToManyField
from django.db import models

class Gallery(models.Model):
    photos = SortedManyToManyField('Photo')

gallery = Gallery.objects.create(name='My Gallery')
for photo in Photo.objects.order_by('name'):
    gallery.photos.add(photo)  # order is preserved

Verify before relying

  • Whether the package supports Django versions earlier than 4.2 (version 4.0.0 dropped support for outdated versions, but exact cutoff is unclear).
  • Performance characteristics when managing large numbers of related objects or complex sort operations.

Package facts

LicenseBSD permissive
Python supportNot specified
Install frictionLow. Pure-Python wheel
Runtime dependenciesNone
MaintenanceActively maintained 733 days since the last release
Last repo commit
First released
Downloads389,270 / month, #7,032 on PyPI 30-day window, as of 2026-08-14
Known vulnerabilitiesNone known OSV.dev, checked 2026-08-14
Classifiers
Development Status :: 5 - Production/StableEnvironment :: Web EnvironmentFramework :: DjangoFramework :: Django :: 4.2Framework :: Django :: 5.0Framework :: Django :: 5.1Intended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseNatural Language :: EnglishOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9

Evidence: django_sortedm2m-4.0.0-py2.py3-none-any.whl

Tags

Capabilities
django ordered many to manydjango m2m with sort orderdjango sortedm2m fieldpreserve relation order djangodjango admin drag drop relations
Topics
django-ormmodel-fields

Let your AI agent find packages like this

Example. Real query, live index.

You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.

wish › “django ordered many to many”

Give your agent the search over MCP, or paste the wish link into any chat.

More Dynamic Content packages

MarkupSafe Worth it
PyPI · Dynamic Content · released Sep 2025

MarkupSafe provides a text object that escapes special characters so untrusted strings can be safely embedded in HTML and XML without injection attacks.

BSD-3-Clausecompiled wheel · 3.9+aging
797.1Mdownloads / mo
Jinja2 Worth it
PyPI · Dynamic Content · released Mar 2025

Jinja2 is a templating engine that renders dynamic content by combining templates with Python-like syntax and data, supporting template inheritance, macros, autoescaping, and sandboxed execution.

BSD-3-Clausepure Python · 3.7+aging
718.6Mdownloads / mo
soupsieve Worth it
PyPI · Python Modules · released Aug 2026

Soupsieve is a CSS selector library designed to work with Beautiful Soup 4 to select, match, and filter HTML and XML elements using modern CSS selectors from CSS level 1 through CSS level 4 specifications.

Install it if you use Beautiful Soup for HTML or XML parsing and want modern CSS selector support.

MITpure Python · 3.10+
428.6Mdownloads / mo
Werkzeug Worth it
PyPI · Application Frameworks · released Apr 2026

Werkzeug is a WSGI utility library providing request/response objects, URL routing, an interactive debugger, HTTP utilities, and a development server for building web applications.

BSD-3-Clausepure Python · 3.9+
268.1Mdownloads / mo
Flask Worth it
PyPI · Application Frameworks · released Feb 2026

Flask is a lightweight WSGI web application framework for building web applications in Python, from simple single-page sites to complex multi-route applications.

BSD-3-Clausepure Python · 3.9+
211.4Mdownloads / mo
Mako Worth it
PyPI · Dynamic Content · released Aug 2026

Mako compiles Python-embedded templates into Python modules for fast rendering, supporting layout inheritance, custom functions, and direct Python expressions within template syntax.

MITpure Python · 3.10+
201.7Mdownloads / mo

See also django-ajax-selects · django-more-admin-filters · django-taggit · django-reverse-admin · django-admin-sortable2 · django-ordered-model · django-recurrence · django-modelcluster · dj-inmemorystorage · django-safedelete