Django Unfold supports sortable changelists, enabling intuitive drag-and-drop reordering of records directly within the changelist (list view) of the admin interface.
To enable sortable functionality on the changelist page:
PositiveIntegerField
with db_index=True
for optimal database performance.Meta.ordering
or set via queryset ordering.ordering_field
on your ModelAdmin
and set hide_ordering_field=True
if you want to hide the field from the list display.# models.py
from django.db import models
from django.utils.translation import gettext_lazy as _
class MyModel(models.Model):
weight = models.PositiveIntegerField(_("weight"), default=0, db_index=True)
class Meta:
ordering = ["weight"]
# admin.py
from django.contrib import admin
from unfold.admin import ModelAdmin
from .models import MyModel
@admin.register(MyModel)
class SomeAdmin(ModelAdmin):
ordering_field = "weight"
hide_ordering_field = True # default: False
© 2023 - 2025 Created by unfoldadmin.com. All rights reserved.