Skip to main content

Reordering List View

You can enable manual reordering of items within the SBAdmin list view using the sbadmin_list_reorder_field. This allows admins to define the visible order of items using drag-and-drop, even when pagination is enabled.

Reorder

Prerequisites​

To enable reordering:

  1. Your model must include a field (e.g. order_by) to track order.
  2. You must configure both sbadmin_list_reorder_field and ordering.

💡Example​

catalog/sb_admin.py
@admin.register(ReorderModel, site=sb_admin_site)
class ReorderModelSBAdmin(SBAdmin):
model = ReorderModel

# Enables reordering via drag-and-drop
sbadmin_list_reorder_field = "order_by"
ordering = ["order_by"]

# Basic list view config
sbadmin_list_display = ["name"]
search_fields = ["name"]

fieldsets = [
(None, {"fields": ["name"]}),
]

Once enabled, a Reorder button will appear in the list view toolbar. Reorder

Clicking it will redirect to a special Reorder View, where you can: Drag and drop rows to change order.

Keep in mind

If you are testing this functionality in Demo project, database works in read-only mode. Reorder will not save.