Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/319.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Django==2.1.4-博客_Python_Django_Blogs - Fatal编程技术网

Python Django==2.1.4-博客

Python Django==2.1.4-博客,python,django,blogs,Python,Django,Blogs,我正在做django项目2.1.4,得到以下错误,我搜索了一下,似乎我一个接一个地修复了错误,但我设法解决了一些。 然而这些我能找到任何线索 运行服务器或迁移后出错。 您需要向模型表单添加“字段”或“排除”属性 # example model: class Comments(models.Model): first_name = models.CharField(max_length=30) last_name = models.CharField(max_length=30)

我正在做django项目2.1.4,得到以下错误,我搜索了一下,似乎我一个接一个地修复了错误,但我设法解决了一些。 然而这些我能找到任何线索

运行服务器或迁移后出错。
您需要向模型表单添加“字段”或“排除”属性

# example model:
class Comments(models.Model):
    first_name = models.CharField(max_length=30)
    last_name = models.CharField(max_length=30)
    comment = models.TextField()
# forms:
class CommentForm(forms.ModelForm):
    class Meta(object):
        model = Comments
        exclude = ['first_name', ] 
        # or:
        fields = ['comments', ]

从您的
评论表单
可以看出,您将
字段
拼写为
文件
。请更正此错误以修复此问题:

class CommentForm(forms.ModelForm): 
    class Meta: 
        model = Comment 
        fields = ('author','text',)  # Use correct spelling
        widgets = { 
            'author':forms.TextInput(attrs={'class':'textinputclass'}), 
            'text':forms.Textarea(attrs={'class':'editable medium-editor-textarea'}) 
        }

你能把
CommentForm
的代码贴出来吗。回溯表明
CommentForm
类缺少一些必需的属性。@Mahmoud-当您将材料添加到问题中时,可以删除注释。通过单击注释日期/时间附近的红色“x”来删除注释。非常感谢我修复了这些问题和字段,它现在正在运行。我发现此错误与“未找到登录”相反“登录名”不是有效的视图函数或模式名。@Mahmoud-最好为此提交一个新问题
class CommentForm(forms.ModelForm): 
    class Meta: 
        model = Comment 
        fileds = ('author','text',) 
        widgets = { 
            'author':forms.TextInput(attrs={'class':'textinputclass'}), 
            'text':forms.Textarea(attrs={'class':'editable medium-editor-textarea'}) 
        }
# example model:
class Comments(models.Model):
    first_name = models.CharField(max_length=30)
    last_name = models.CharField(max_length=30)
    comment = models.TextField()
# forms:
class CommentForm(forms.ModelForm):
    class Meta(object):
        model = Comments
        exclude = ['first_name', ] 
        # or:
        fields = ['comments', ]
class CommentForm(forms.ModelForm): 
    class Meta: 
        model = Comment 
        fields = ('author','text',)  # Use correct spelling
        widgets = { 
            'author':forms.TextInput(attrs={'class':'textinputclass'}), 
            'text':forms.Textarea(attrs={'class':'editable medium-editor-textarea'}) 
        }