Refactored model files
This commit is contained in:
50
techdb/flightslot/models/students.py
Normal file
50
techdb/flightslot/models/students.py
Normal file
@@ -0,0 +1,50 @@
|
||||
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}"
|
||||
Reference in New Issue
Block a user