def save_model(self, request, obj, form, change):
if self._state.adding is True:
super(TaskAdmin, self).save_model(request, obj, form, change)
else:
if 'hours_per_day' in form.changed_data:
messages.info(request, "Hours per Day has changed.")
if date.today():
TaskHourChange.objects.filter(date_changed=date.today()).delete()
taskchange = TaskHourChange.objects.create(
date_changed=date.today(), prev_hours_per_day=obj.hours_per_day, task=obj)
taskchange.save()
else:
messages.info(request, "Hours per Day has not changed")
super(TaskAdmin, self).save_model(request, obj, form, change)
Я попробовал это, и это не работает. Я хочу проверить, обновлен или вставлен объект.