0
我想要一個用戶能夠創建一個Store
對象。創建後,它應自動爲此用戶/商店組合創建EmploymentRelationship
類型爲Owner
。稍後,商店的Owner
能夠添加Employee
。儘管在管理界面中創建對象時,如何創建這種初始關係?如何在創建對象時自動創建Django關係?
class Store(models.Model):
description = models.CharField('Description of Store',max_length=45, null=False, blank=False)
class EmploymentRelationship(models.Model):
OWNERTYPECHOICES = (
(constants.OWNER, 'Owner'),
(constants.EMPLOYEE, 'Employee'),
)
sid = models.ForeignKey(Store, null=False, blank=False)
uid = models.ForeignKey(User, null=False, blank=False)
employment_type = models.IntegerField('Ownership Type',default=constants.EMPLOYEE, choices=OWNERTYPECHOICES)