2012-05-12 10:24:20 +03:00
|
|
|
from django.db import models
|
|
|
|
|
2013-11-02 16:34:05 -05:00
|
|
|
|
2012-05-12 10:24:20 +03:00
|
|
|
class Account(models.Model):
|
|
|
|
num = models.IntegerField()
|
|
|
|
|
|
|
|
|
|
|
|
class Person(models.Model):
|
2018-12-10 19:58:49 +05:30
|
|
|
GENDER_CHOICES = (
|
2022-02-03 20:24:19 +01:00
|
|
|
("M", "Male"),
|
|
|
|
("F", "Female"),
|
2018-12-10 19:58:49 +05:30
|
|
|
)
|
2012-05-12 10:24:20 +03:00
|
|
|
name = models.CharField(max_length=20)
|
|
|
|
gender = models.CharField(max_length=1, choices=GENDER_CHOICES)
|
2012-08-12 22:17:54 +03:00
|
|
|
pid = models.IntegerField(null=True, default=None)
|
2012-05-12 10:24:20 +03:00
|
|
|
|
|
|
|
|
|
|
|
class Employee(Person):
|
|
|
|
employee_num = models.IntegerField(default=0)
|
2022-02-03 20:24:19 +01:00
|
|
|
profile = models.ForeignKey(
|
|
|
|
"Profile", models.SET_NULL, related_name="profiles", null=True
|
|
|
|
)
|
|
|
|
accounts = models.ManyToManyField("Account", related_name="employees", blank=True)
|
2012-05-12 10:24:20 +03:00
|
|
|
|
|
|
|
|
2020-08-11 21:05:03 -04:00
|
|
|
class NonConcreteField(models.IntegerField):
|
|
|
|
def db_type(self, connection):
|
|
|
|
return None
|
|
|
|
|
|
|
|
def get_attname_column(self):
|
|
|
|
attname, _ = super().get_attname_column()
|
|
|
|
return attname, None
|
|
|
|
|
|
|
|
|
2012-05-12 10:24:20 +03:00
|
|
|
class Profile(models.Model):
|
|
|
|
name = models.CharField(max_length=200)
|
|
|
|
salary = models.FloatField(default=1000.0)
|
2020-08-11 21:05:03 -04:00
|
|
|
non_concrete = NonConcreteField()
|
2012-05-12 10:24:20 +03:00
|
|
|
|
|
|
|
|
|
|
|
class ProxyEmployee(Employee):
|
|
|
|
class Meta:
|
|
|
|
proxy = True
|