'Altering a Django model values based on a few conditionals? What is the best practice way to do this?
I have the model SyncCollector
that has the field status
. status
is one of statusIntervalEnum
. I want to change the existing ones that are statusIntervalEnum.DYNAMIC
to 'statusIntervalEnum.STATIC.
Now I know that I can do a SyncCollector.objects.filter(status=statusIntervalEnum.DYNAMIC)
and loop through all of them and save them and perhaps trigger it through a custom endpoint that I later take away, but what is the best way to do this for a production instance?
Making a fake endpoint that I just call in prod to run this seems very hacky.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|