django-admin-sortable

raw JSON →
2.3 verified Fri May 01 auth: no python maintenance

A Django library that provides drag-and-drop sorting for models and inline models in the Django admin interface. Version 2.3 is the latest stable release, but the project appears to be in maintenance mode with infrequent updates.

pip install django-admin-sortable
error ModuleNotFoundError: No module named 'adminsortable'
cause Library not installed or not in INSTALLED_APPS.
fix
Run 'pip install django-admin-sortable' and add 'adminsortable' to INSTALLED_APPS.
error ImproperlyConfigured: 'ordering' attribute is required for sortable models.
cause Model inherits from Sortable but does not define an ordering field or Meta class.
fix
Add class Meta(Sortable.Meta): pass to the model.
error django.core.exceptions.FieldDoesNotExist: Category has no field named 'my_order'
cause The default order field name is 'my_order', but the field does not exist in the model.
fix
Either add a PositiveIntegerField named 'my_order' to the model, or define order_field_name in the Meta class.
breaking Sortable model must inherit from Sortable (not SortableMixin) and set Meta as shown. Failing to include Sortable.Meta will cause errors like 'No order field found'.
fix Ensure model inherits from `adminsortable.models.Sortable` and includes `class Meta(Sortable.Meta): pass`
deprecated This library is not actively maintained. It may not work with Django 3.x+ due to admin template changes. Consider alternatives like django-admin-sortable2 (django-admin-sortable2).
fix Switch to django-admin-sortable2 for better Django 3+/4+ support.
gotcha Inline sorting (SortableTabularInline, SortableStackedInline) often fails if the parent model is not also sortable. Inline sort order may not save correctly.
fix Ensure parent model uses Sortable mixin or admin uses SortableAdminMixin.

Basic setup: add app, define Sortable model, use SortableAdminMixin in admin, and reorder data.

# settings.py
INSTALLED_APPS = [
    ...
    'adminsortable',
]

# models.py
from django.db import models
from adminsortable.models import Sortable

class Category(Sortable):
    name = models.CharField(max_length=100)

    class Meta(Sortable.Meta):
        pass

    def __str__(self):
        return self.name

# admin.py
from django.contrib import admin
from adminsortable.admin import SortableAdminMixin
from .models import Category

class CategoryAdmin(SortableAdminMixin, admin.ModelAdmin):
    list_display = ('name', 'my_order')

admin.site.register(Category, CategoryAdmin)

# After migrating, run:
python manage.py reorder <app_label> <model_name>