A Django App that highlights selected rows after executing custom action on the admin UI.
Django admin actions allow you to hook up your custom actions. But after you select the rows and execute your own action, the selected states of rows will be reset.
This app can help keeping the selected states of the rows.
pip install django-highlightselect-model-admin
INSTALLED_APPS = [
...
'highlightselect_model_admin',
...
]
python manage.py collectstatic
from highlightselect_model_admin import HighLightSelectModelAdmin
from .model import MyModel
@admin.register(MyModel)
class MyModelAdmin(HighLightSelectModelAdmin):
"""
Inherit from HighLightSelectModelAdmin insead of django.contrib.admin.ModelAdmin
"""
...
action = ('my_action', )
def my_action(self, request, queryset):
selected_ids = []
for q in queryset:
selected_ids.append(q.id)
self.highlight_message_user(request, 'Selected!', selected_ids)
https://github.com/laonan/django-highlightselect-model-admin/issues