action_hero.actions.simple

Provides the simplest possible implementation of AdminActionBaseClass.

class action_hero.actions.simple.SimpleAction

Bases: AdminActionBaseClass

Generates an admin action calling a function for a chosen set of records.

This is the simplest “useful” implementation of AdminActionBaseClass. It only calls the provided function with the primary key of each record in the queryset. Because the default condition is always True, 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.title on each record’s title attribute. 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.