Django ship a default action “Delete selected <objects>”, how can we add a new action? It is easy to do that. All you need to do are in admin.py where the model admins are registered.
First write your action handler function like this
def tasks_finished( modeladmin, request, queryset ):
queryset.update( finished = True )
tasks_finished.short_description = "Mark these tasks as finished"
Then register the handler in your model admin site
class TaskAdmin( admin.ModelAdmin ):
list_display = [ "project", "title", "user", "works", "time", "finished" ]
list_filter = [ "finished", "user", "project" ]
inlines = [ WorkAdminInline ]
ordering = [ "project", "finished", "user", "title" ]
actions = [ tasks_finished ]
That is all you need to do.
This blog appears to get a great deal of visitors. How do you get traffic to it? It offers a nice individual twist on things. I guess having something real or substantial to talk about is the most important thing.
trying to follow you on twitter but cant find your name