15๐
โ
Not is not supported here. You will have to use Case When
from django.db.models import Case, Value, When
Item.objects.filter(serial__in=license_ids
).update(renewable=Case(
When(renewable=True, then=Value(False)),
default=Value(True))
)
)
๐คe4c5
17๐
You can also do:
Item.objects.filter(serial__in=license_ids).update(renewable=Q(renewable=False))
when renewable is True
=> Q object condition will give False
when renewable is False
=> Q object condition will give True
๐คRishabh Gupta
- In MVC (eg. Django) what's the best place to put your heavy logic?
- How to test django caching?
- How to raise a error inside form_valid method of a CreateView
- Use Django dumpdata to dump a subset of overall data?
- Django Test Run Environment error: no enough space left on disk
Source:stackexchange.com