Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否可以在保存内联时检测到哪些字段发生了更改?我使用 save_formset 方法,但不知道如何检测更改的字段。我需要它来检测图像是否在管理员中被清除。
从数据库中检索现有条目,然后将其与您要保存的条目进行比较是实现此目的的一种非常简单的方法。
existing_entry = Model.objects.get(pk=entry_to_save.pk) if existing_entry.image != entry_to_save.image: # Your image has been modified entry_to_save.save()