from django.db import models
from .major import Major
from .user import User


class Student(models.Model):
    """A class that inherits from the model class which 
    create a Student model.This Student model defines a 
    datastore entity.
    This class is ordering by major.

    Args:
        models (_type_): model class

    Returns:
        _type_: string object (Student.user.pid and Student.user.username)
    """
    user = models.OneToOneField(
        User, on_delete=models.CASCADE, primary_key=True)
    major = models.ForeignKey(Major, on_delete=models.CASCADE)
   

    def __str__(self) -> str:
        return f'Student: {self.user.pid} {self.user.username}'

    class Meta:
        ordering = ['major']
