Files
catops/techdb/flightslot/models/students.py
2025-11-14 12:01:14 +01:00

51 lines
926 B
Python

from django.db import models
from django.contrib.auth.models import User
from ..models.courses import Course
class Student(models.Model):
id = models.AutoField(
primary_key=True
)
email = models.EmailField(
null=False,
db_index=True
)
phone = models.CharField(
null=True,
max_length=16
)
name = models.CharField(
null=False,
max_length=32
)
surname = models.CharField(
null=False,
max_length=32
)
course = models.ForeignKey(
Course,
on_delete=models.DO_NOTHING,
null=True
)
active = models.BooleanField(
null=False,
default=True
)
user = models.OneToOneField(
User,
on_delete=models.CASCADE,
null=True,
blank=True
)
def __str__(self):
return f"{self.surname} {self.name[0]}. => {self.course}"