Skip to content

Instantly share code, notes, and snippets.

@sankalpjonn
Last active May 22, 2021 11:38
Show Gist options
  • Save sankalpjonn/cc84f53581b11eeb3ffb452a988662b1 to your computer and use it in GitHub Desktop.
Save sankalpjonn/cc84f53581b11eeb3ffb452a988662b1 to your computer and use it in GitHub Desktop.
from django.db import models
#======= Abstract models =========#
class Person(models.Model):
name = models.CharField(max_length=255)
date_of_birth = models.DateTimeField()
date_of_joining = models.DateTimeField()
address = models.TextField()
class Meta:
abstract = True
class SchoolEmployee(Person):
compensation = models.CharField(max_length=255)
class Meta:
abstract = True
class HiredHelp(SchoolEmployee):
shift_timings = models.JSONField()
class Meta:
abstract = True
#--------------------------------#
#======= Actual models ==========#
class Student(Person):
roll_number = models.IntegerField()
class Teacher(SchoolEmployee):
qualifications = models.JSONField()
class CafeteriaEmployee(HiredHelp):
pass
class CleaningStaffMember(HiredHelp):
pass
#--------------------------------#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment