Update dta_service/core/models.py

This commit is contained in:
2025-07-12 16:52:35 +00:00
parent 3f3fa4b3d8
commit 848d030b08

View File

@@ -8,6 +8,28 @@ from django.conf import settings
import uuid
import os
class TimeInfoBase(models.Model):
created = models.DateTimeField(default=timezone.now)
last_modified = models.DateTimeField(default=timezone.now)
class Meta:
abstract = True
def save(self, *args, **kwargs):
if not kwargs.pop("skip_last_modified", False) and not hasattr(
self, "skip_last_modified"
):
self.last_modified = timezone.now()
if kwargs.get("update_fields") is not None:
kwargs["update_fields"] = list(
{*kwargs["update_fields"], "last_modified"}
)
super().save(*args, **kwargs)
class UserManager(BaseUserManager):
def create_user(self, email, password=None, **extra_fields):
if not email: