Polymorphic model correctly saves, fixed formatting of admin

This commit is contained in:
2025-11-21 17:49:51 +01:00
parent 02990d4b2f
commit 48ff1d799c
7 changed files with 105 additions and 30 deletions

View File

@@ -51,7 +51,7 @@ class Student(models.Model):
# Override save method to add user for login upon Student creation
def save(self, *args, **kwargs):
creating = self.pk is None
creating: bool = self.pk is None
super().save(*args, **kwargs)
if creating and not self.user:
username = f"{self.name.lower()}.{self.surname.lower()}"
@@ -68,7 +68,7 @@ class Student(models.Model):
username=username,
email=self.email,
password=self.default_password(),
is_staff=True
is_staff=True # allows access to admin page
)
student_group, _ = Group.objects.get_or_create(name="StudentGroup")