我在Employee和Manager類之間有繼承關係。 Employee - 超類,Manager - 子類。Django,Python繼承:從超類中排除一些字段
class Employee(models.Model):
###
name = models.CharField(max_length=50, null=False)
address = models.CharField(max_length=50, null=False)
###
class Manager(Employee):
department = models.CharField(max_length=50)
###
here I don't want the 'name' and 'address' fields of Employee class.
(I want other fields of Employee and department field of this class to be stored in
Manager table in database)
###
怎麼能實現這個。提前致謝。
即使這是可能的,這將使'經理'沒有名字。你確定你想要嗎? –
在其他語言中,您可以將'Employee'' private'字段與'public'或'protected'字段相對應。 –
爲什麼你不使用foreingkey? –