You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
auto_now fields are not updated on calling .update() method.
auto_now fields are updated only if .save() method is called on model instance.
Be aware that update() does an update at the SQL level and, thus, does not call any save() methods on your models, nor does it emit the pre_save or post_save signals (which are a consequence of calling Model.save()
Based on your scenario, you need to get item, set attribute you want to update and save the instance
@app.put("/movies/{pk}")asyncdefupdate_movie(pk: int, movie_in: MovieIn):
movie=awaitMovie.filter(id=pk).first()
ifmovie:
# Your staffsawaitmovie.save()
return# Your staffsreturn# Your staffs
Describe the bug
I use auto_now in my model,but when I use update method ,its updated time doesn't update
update mtheod
model
Expected behavior
auto_now works when I update data
The text was updated successfully, but these errors were encountered: