2016-12-01 9 views
0

$ "python manage.py runserver localhost:8000"を実行しようとすると、以下の例外エラーが発生します。Djangoで説明できないエラー

助けてください!私は間違って何をしています。

 
Request Method: GET 
Django Version: 1.8.13 
Exception Type: TypeError 
Exception Value:  
__init__() takes 1 positional argument but 2 were given 
Exception Location: /usr/local/lib/python3.4/site-packages/django/core/handlers/base.py in get_response, line 132 
Python Executable: /usr/local/bin/python3.4 
Python Version: 3.4.4 

views.py

class CreateMsg(CreateView): 
    #model = Visitor 
    form_class = Msg 
    template_name = "message.html" 

forms.py

class Msg(forms.ModelForm): 
    class Meta: 
     model = Visitor 
     fields = ['name', 'contact', 'message'] 

メイン/ urls.py

urlpatterns = [ 
    url(r'^contact/', include('msgapps.urls')), 
] 

msgapps/url.py

urlpatterns = patterns(
    'msgapps.views', 
    url(r'^msg/$', CreateMsg, name='CreateMsg'), 
) 

答えて

5

あなたが.as_view()を追加する必要がありますURLでCBVを使用するには:

urlpatterns = patterns(
    'msgapps.views', 
    url(r'^msg/$', CreateMsg.as_view(), name='CreateMsg'), 
) 
+0

おかげPythad。優れた。 – Divino

関連する問題