How can I copy a queryset to a new model in django admin?

Posted by user3806832 on Stack Overflow See other posts from Stack Overflow or by user3806832
Published on 2014-08-19T04:17:38Z Indexed on 2014/08/19 4:19 UTC
Read the original article Hit count: 250

I'm trying to write an action that allows the user to select the queryset and copy it to a new table. So:

John, Mark, James, Tyler and Joe are in a table 1( called round 1)

The user selects the action that say to "move to next round"

and those same instances that were chosen are now also in the table for "round 2".

I started trying with an action but don't really know where to go from here:

def Round_2(modeladmin, request, queryset):

       For X in queryset:
           X.pk = None

       perform.short_description = "Move to Round 2"

How can I copy them to the next table with all of their information (pk doesn't have to be the same)? Thanks

© Stack Overflow or respective owner

Related posts about django

Related posts about django-models