Django FieldError at / Unknown字段(类型)为Model指定

时间:2017-03-13 08:51:00

标签: django

我在Model / / p>指定的/ Unknown字段(类型)中有FieldError

我的模特:

class SocialNetwork(models.Model):
    contact = models.ForeignKey(Contact, related_name='social_networks')
    handle = models.CharField(max_length =50)
    types = models.CharField(max_length=20, choices = SOCNET_TYPES)
    public_visible = models.BooleanField(default=False)
    contact_visible = models.BooleanField(default=False)

    @property
    def url(self):
        prefixes = social_net_prefixes
        prefix = getattr(settings, '%s_PREFIX' % self.type.upper(), prefixes[self.type])
        return '%s%s' % (prefix, self.handle)

    def __unicode__(self):
        return "%s %s: %s" % (self.contact.first_name, self.type, self.handle)

我的formModel:

class SocialNetworkForm(ModelForm):
    class Meta:
        model = SocialNetwork
        fields = ('handle', 'type', 'public_visible', 'contact_visible')

我做错了什么?

1 个答案:

答案 0 :(得分:1)

在表格变更中:

'type' into 'types'