相关疑难解决方法(0)

RemovedInDjango18Warning:不建议使用'fields'属性或'exclude'属性创建ModelForm

我正在做一个Django项目,当我尝试访问127.0.0.1:8000/articles/create时,我的Ubuntu终端出现以下错误:

/home/(my name)/django_test/article/forms.py:4: RemovedInDjango18Warning:  Creating a ModelForm without either the 'fields' attribute or the 'exclude' attribute is deprecated - form ArticleForm needs updating
class ArticleForm(forms.ModelForm):
Run Code Online (Sandbox Code Playgroud)

另外,访问我的实际localhost站点时,我也遇到以下错误:

ValueError at /articles/create/

The view article.views.create didn't return an HttpResponse object. It returned None instead.
Run Code Online (Sandbox Code Playgroud)

这是我的forms.py文件:

from django import forms
from models import Article

class ArticleForm(forms.ModelForm):

    class Meta:
        model = Article 
Run Code Online (Sandbox Code Playgroud)

这是我的views.py文件:

from django.shortcuts import render_to_response
from article.models import Article
from django.http import HttpResponse
from forms import ArticleForm
from django.http import HttpResponseRedirect
from django.core.context_processors …
Run Code Online (Sandbox Code Playgroud)

python django

30
推荐指数
3
解决办法
4万
查看次数

标签 统计

django ×1

python ×1