为Django模型中的字段添加额外的选择

时间:2014-03-31 00:00:24

标签: django

如果我希望以后能够在Role类中为我的TYPES_CHOICES元组添加额外的选择,那将如何实现?用表格?

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)
    role = models.ForeignKey(Role)

class Role(models.Model)
    TYPES_CHOICES = (
    ('PLAYER', 'Player'),
    ('CONDUCTOR', 'Conductor'),
    ('COMMITTEEMEMBER', 'Committee Member'),
    ('LIBRARIAN', 'Librarian'),
    ('TUTOR', 'Tutor'),
    ('ACOCOUNTANT', 'Accountant'),
    ('PRESIDENT', 'President'),
    ('CHAIRMAN', 'Chairman'),
    ('SECRETARY', 'Secretary')
    )
    type = models.CharField(_('Type'), max_length = 20, choices = TYPES_CHOICES)

0 个答案:

没有答案