I'm trying to change the value of a BooleanField in one of my models, but Django won't let me. Here's the relevant code:
query = MyModel.objects.filter(name='example').filter(boolField=False)
print query[0].boolField
query[0].boolField = True
query[0].save()
print query[0].boolField
This surprisingly prints:
False
False
Any idea why the = True
isn't sticking? Thanks in advance!
Edit: This fixed it:
query = MyModel.objects.get(name='example', boolField=False)
query.boolField = True
query.save()
It seems you can't change fields in a query that you filtered by?