I want to create a Django Admin Action that allows me to create a duplicate of a record.
Heres the use case.
Admin clicks the checkbox next to a record in an app that they want to duplicate. Admin selects "Duplicate" from the admin action drop down menu. Admin clicks go. Django admin creates a duplicate record with a new id. Page is refrshed and new duplicate is added with id. Admin clicks on the new, duplicated record, and edits it. Admin clicks save.
Am I crazy or is this a pretty straight forward Admin Action?
I've been using these docs for reference: http://docs.djangoproject.com/en/dev/ref/contrib/admin/actions/
I'm thinking something like this:
In my app:
def duplicate(modeladmin, request, queryset):
new = obj.id
queryset.create(new)
return None
duplicate.short_description = "Duplicate selected record"
I know that's not right... but is my thinking close?