我试图做到这一点,只有当MusicPackState.type
等于loan
时才有
对正在借给它的会员的提及。我是否采取正确的方式来做这件事?
class Member(models.Model):
firstName = models.CharField(max_length = 20)
lastName = models.CharField(max_length = 20)
address = models.ForeignKey(models.ForeignKey(Address)
memberContactInfo = models.ForeignKey(MemberContactInfo)
class MusicPack(models.Model)
title = models.CharField(max_length = 20)
composer = models.CharField(max_length = 20)
arranger = models.CharField(max_length = 20)
class MusicPackState(models.Model)
TYPES_CHOICES = (
('ISSUED', 'Issued'),
('LIBRARY', 'Library'),
('LOAN', 'Loan'),
('ENTERTAINMENTFOLDER', 'Entertainment Folder')
)
type = models.CharField(_('Type'), max_length = 20, choices = TYPES_CHOICES)
def if_loan(self)
if type == 'Loan'
member = models.ForeignKey(Member)