Puoi creare una query in modo programmatico, utilizzando i condizionali Case
e When
.
Quindi, ad esempio:
from django.db.models import Case, When
# Make a list of When expressions
when_list = [When(priority_number=2, then=3),
When(priority_number=3, then=4)]
# Use in a query of your choice, as an example:
Model.objects.update(
priority_number=Case(
*when_list))