mirror of
https://github.com/lemeow125/StudE-Backend.git
synced 2024-11-17 06:19:24 +08:00
23 lines
679 B
Python
23 lines
679 B
Python
from django.db import models
|
|
from django.db.models.signals import post_migrate
|
|
from django.dispatch import receiver
|
|
|
|
# Create your models here.
|
|
|
|
|
|
class Semester(models.Model):
|
|
name = models.CharField(max_length=64, unique=True)
|
|
shortname = models.CharField(max_length=16, unique=True)
|
|
|
|
def __str__(self):
|
|
return self.name
|
|
|
|
|
|
@receiver(post_migrate)
|
|
def populate_semesters(sender, **kwargs):
|
|
if sender.name == 'semesters':
|
|
Semester.objects.get_or_create(
|
|
name='1st Semester', shortname='1stSem')
|
|
Semester.objects.get_or_create(
|
|
name='2nd Semester', shortname='2ndSem')
|
|
# Add more predefined records as needed
|