Detect if a model has changed before calling save in Django

后端 未结 5 2110
Happy的楠姐
Happy的楠姐 2020-12-08 21:19

I have a database model that is being updated based on changes in remote data (via an HTML scraper).

I want to maintain a field called changed - a times

5条回答
  •  南方客
    南方客 (楼主)
    2020-12-08 21:35

    Sounds to me like what you want is Signals: http://docs.djangoproject.com/en/1.2/topics/signals/

    You could use a post_save signal to update a related field in another model to store the previous value. Then on the next go-round you'd have something to compare.

提交回复
热议问题