def save(self, *args, **kw):
if self.pk is not None:
orig = MyModel.objects.get(pk=self.pk)
field_names = [field.name for field in MyModel._meta.fields]
fields_stats = {}
for field_name in field_names:
fields_stats[field_name] = getattr(orig, field_name) != getattr(self, field_name)
super(MyModel, self).save(*args, **kw)
Then field_stats
will be
{
'field_name1': True,
'field_name1': False,
}
'backend > django' 카테고리의 다른 글
Django: multiple choices in django admin list_filter (0) | 2018.05.09 |
---|---|
Django: custom filter for list_filter in admin (0) | 2018.05.05 |
Django: ModelChoiceField - prepopulate choice field with row from model (0) | 2018.05.03 |
Django: disable password check (password2) in django-allauth (0) | 2018.05.02 |
Django: reset migrations (0) | 2018.04.30 |