From 3151bf50c2581241cae68bfbcaf6035481e07368 Mon Sep 17 00:00:00 2001 From: yuetsh <517252939@qq.com> Date: Sun, 27 Apr 2025 19:06:51 +0800 Subject: [PATCH] fix --- account/models.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/account/models.py b/account/models.py index e694b56..841cf24 100644 --- a/account/models.py +++ b/account/models.py @@ -29,9 +29,10 @@ class User(AbstractUser): ) def save(self, *args, **kwargs): - if self.is_superuser: - self.role = RoleChoices.SUPER - super().save(*args, **kwargs) + if self.username: + if self.is_superuser: + self.role = RoleChoices.SUPER + super().save(*args, **kwargs) def set_password(self, raw_password): super().set_password(raw_password)