我检查了文档,但问题仍未解决。 我的forms.py文件中的语法无效
from django import forms
from blog.models import Post,Comment
class PostForm(forms.ModelForm):
class Meta():
model = post
fields = ('author', 'title','text')
widgets = {
'title':forms.TextInput(attrs={'class':'textinputclass'}),
'text':forms.Textarea(attrs={'class':'editable medium-editor-textarea postcontent'})
}
class CommentForm(forms.ModelForm):
class Meta():
model = Comment
fields = ('author', 'text')
widgets = {
'author': forms.TextInput(attrs={'class':'textinputclass'})
'text': forms.Textarea(attrs={'class':'editable medium-editor-textarea'})
}
我正在尝试部署我的第一个Django应用程序(研究目的)。出现此错误时,差不多完成了。
答案 0 :(得分:1)
class PostForm(forms.ModelForm):
class Meta():
model = Post # this needs to be Post not post
fields = ('author', 'title','text')