prohibited to prevent data loss due to unsaved related object 'employee'.
Переопределил метод save()
def save(self, force_insert=False, force_update=False, using=None, update_fields=None):
if not self.pk:
LoggingEmployeeChanges.objects.using('db').create(
employee=self,
action_flag=ADDITION,
change_message=_("Added")
)
else:
LoggingEmployeeChanges.objects.using(‘db’).create(
employee=self,
action_flag=CHANGE,
change_message=_("Changed")
)
super(Employee, self).save(using=‘db’)
супер наерх подними. нет id у self
Обсуждают сегодня