Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- obj = MyModel.objects.create(val=1)
- MyModel.objects.filter(pk=obj.pk).update(val=F('val') + 1)
- # At this point obj.val is still 1, but the value in the database
- # was updated to 2. The object's updated value needs to be reloaded
- # from the database.
- # approach 1)
- obj = MyModel.objects.get(pk=obj.pk)
- # approach 2)
- obj.refresh_from_db()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement