Такой метод не работает if not self.pk
def save(self, force_insert=False, force_update=False, using=None, update_fields=None):
super(Employee, self).save(using='db')
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")
)
if self._state.adding https://docs.djangoproject.com/en/2.0/ref/models/instances/
Обсуждают сегодня