我是Django的新手,嘗試使用CBV爲我的'Project'模型生成表單。當我使用CreateView.as_view(...)在urls.py它給出以下錯誤。無法在Django中使用CreateView.as_view
Exception Type: ImproperlyConfigured
Exception Value: Using ModelFormMixin (base class of CreateView) without the 'fields' attribute is prohibited.
我在此列出與此視圖相關的完整代碼。
urls.py
url(r'^create-project/$', CreateView.as_view(model=Project,
template_name='en/public/create_project.html',
success_url='index'),
name='create_project')
create_project.py
class Form_project_create(forms.Form):
class Meta:
model = Project
fields = '__all__'
我想不出我們有什麼錯在此代碼。誰能幫忙?