Created
April 20, 2021 09:01
-
-
Save paulmwatson/c9e2a15376c3c4c6447ab3367e51545f to your computer and use it in GitHub Desktop.
Copies an IDP event and its actions.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from idp_data.idp_data.models import Event, EventAction | |
id = '103' | |
original_event = Event.objects.get(pk=id) | |
new_event = Event.objects.get(pk=id) | |
new_event.pk = None | |
new_event.id = None | |
new_event._state.adding = True | |
new_event.save() | |
new_event.title = f'{original_event.title} - {new_event.id}' | |
new_event.save() | |
for action in original_event.actions.all(): | |
action.pk = None | |
action.id = None | |
action.event = new_event | |
action._state.adding = True | |
action.save() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment