Django: Field Error Unknown fields

喜夏-厌秋 提交于 2019-12-05 15:02:35

问题


I just installed OS X Lion, so I had to reinstall everything for Python2.7. In doing that I upgraded my Django to 1.3 from 1.2.3. When I try and runserver, I get an odd field error that I'm having a tough time deciphering.

FieldError at /
Unknown field(s) (a, m, s, e, g) specified for Note

Here is that Model & Form:

class Note(models.Model):
    pub_date = models.DateTimeField(default=datetime.now, 
        auto_now_add=True, db_index=True)
    user = models.ForeignKey(User, null=True, blank=True, related_name="writers")
    to = models.ForeignKey(User, null=True, blank=True, related_name="tost")
    message = models.CharField(default='', max_length=140)
    active = models.BooleanField(default=True)

class NoteForm(forms.ModelForm):
    class Meta:
        model = Note
        fields = ('message')

    message = forms.CharField(
        label=_("Sign the Guestbook"),
        widget=forms.Textarea,
        required=True)

回答1:


Try

    fields = ('message',)

To create a tuple with only one element.



来源:https://stackoverflow.com/questions/6768194/django-field-error-unknown-fields

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!