Skip to content
Advertisement

how django ‘auto_now’ ignore the update of specified field

i have a model, like this:

Usually, ‘modify_time’ will be updated when i update ‘name’, ‘chasha’, ‘stat’ field. But, I just did not want the ‘modify_time’ been updated when i update ‘stat’. how can i do that?

thanks.

Advertisement

Answer

Use a custom save method to update the field by looking at a previous instance.

Edit: remove auto_now from modify_time like above, otherwise it will be set at the save method.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement