Create Custom Django Admin Actions


Django tip:

You can create custom bulk actions for the Django admin.

Example:

@admin.action(description='Mark selected items purchased')
def make_purchased(modeladmin, request, queryset):
    queryset.update(purchased=True)


@admin.register(ShoppingItem)
class ShoppingItemAdmin(admin.ModelAdmin):
    actions = [make_purchased]