update object without updating auto_now fields

65 views
Skip to first unread message

Mohammad Etemaddar

unread,
Feb 13, 2019, 3:25:54 AM2/13/19
to Django users
I think about times that I need to edit user profiles without touching auto_now field.
How can I do it?

Андрей Маслов

unread,
Feb 13, 2019, 8:48:32 AM2/13/19
to Django users
MyModel.objects.filter(pk=obj.pk).update(...)

The field is only automatically updated when calling Model.save()
The field isn’t updated when making updates to other fields in other ways such as QuerySet.update(), though you can specify a custom value for the field in an update like that.

среда, 13 февраля 2019 г., 10:25:54 UTC+2 пользователь Mohammad Etemaddar написал:
Reply all
Reply to author
Forward
0 new messages