action_hero.actions.simple¶
Provides the simplest possible implementation of AdminActionBaseClass.
- class action_hero.actions.simple.SimpleAction¶
Bases:
AdminActionBaseClassGenerates an admin action calling a function for a chosen set of records.
This is the simplest “useful” implementation of
AdminActionBaseClass. It only calls the providedfunctionwith the primary key of each record in thequeryset. Because the defaultconditionis alwaysTrue, this action will be carried out for every record.Example usage:
titlecase_titles_action = SimpleAction(function=str.title) class MyModelAdmin(admin.ModelAdmin): actions = [titlecase_titles_action] model = MyModel
This will call
str.titleon each record’stitleattribute. Because this doesn’t involve a database write, the change is immediately discarded.- handle_item(item)¶
Handles a single item from the queryset.
- Parameters:
item (Model) – The model instance being processed.