我希望用户能够创建一个Store
对象。创建时,它应该自动创建此用户/商店组合的EmploymentRelationship
类型Owner
。稍后Owner
,商店的 可以添加Employee
。在管理界面中创建对象时,如何建立这种初始关系?
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)