I don’t know how to run a selection from several tables ... So, if you do not want to use my suggestion below, you just need to iterate over all the "updated" models.
However, you might want to consider the UpdatedItems model, which might be something like this:
class ItemUpdate(m.Model): when = m.DateTimeField(...) instance = m.GenericForeignKey(...) field = m.CharField(...) old_value = m.CharField(...) new_value = m.CharField(...)
Then use the post_save signal to populate it:
form django.db.models.signals import post_save def handle_post_save(sender, instance, *args, **kwargs): ItemUpdate(instance=instance, ...).save()
I don’t know how to determine which fields are being updated ... But I'm sure someone asked about this on Google.
source share