Polymorphic model correctly saves, fixed formatting of admin
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user