Going a bit crazy with something that stopped working in my Django app (Django 3.2.5, Python 3.9.6) - here's a simplified version:
class MyModel(models.Model):
attribute_1 = models.CharField(max_length=1, default='0')
myModel = MyModel()
myModel.save()
print(myModel.attribute_1) # OUTPUTS '0'
myModel.attribute_1 = '1' # EDITED MY TYPO HERE...
myModel.save()
print(myModel.attribute_1) # OUTPUTS '1'
The second save()
is not being saved, if I retrieve myModel
from the database elsewhere I get attribute_1
equal to 0
.
This, however, does work as I expect it to:
myModel = MyModel()
myModel.save()
MyModel.filter(pk=myModel.pk).update(attribute_1='1')
Am I missing something incredibly obvious here?