Did you know that model modifications may or may not be updated? I didn't know I checked it
user = User.objects.get(pk=1)
user.name = 'hoge'
user.save()
Well, it ’s a common one.
User.objects.filter(prefecture_id=1).update(prefecture_name='Hokkaido')
It will not be updated using the ʻupdate` method!
User.objects.filter(prefecture_id=1).update(prefecture_name='Hokkaido', modified=datetime.datetime.now())
Must be explicitly specified like this
users = []
for user in User.objects.filter(prefecture_id=1):
user.prefecture_name ='Hokkaido'
user.modified = datetime.datetime.now()
users.append(user)
User.objects.bulk_update(users, fields=['prefecture_name', 'modified'])
bulk_update is not updated as well, so you need to specify it explicitly