When saving, how can you check if a field has changed?

前端 未结 25 1782
鱼传尺愫
鱼传尺愫 2020-11-22 07:15

In my model I have :

class Alias(MyBaseModel):
    remote_image = models.URLField(max_length=500, null=True, help_text=\"A URL that is downloaded and cached          


        
25条回答
  •  一向
    一向 (楼主)
    2020-11-22 07:18

    As of Django 1.8, there's the from_db method, as Serge mentions. In fact, the Django docs include this specific use case as an example:

    https://docs.djangoproject.com/en/dev/ref/models/instances/#customizing-model-loading

    Below is an example showing how to record the initial values of fields that are loaded from the database

提交回复
热议问题