1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

ValueError at / の解消方法備忘録

Posted at

エラー文
ValueError at / The view myapp.views.Index didn't return an HttpResponse object. It returned None instead.

『HttpResponse object』
HttpResponseが返せていないと言う意味。

変更するコード内容

def Index(TemplateView): 
    template_name = 'myapp/imdex.html'

DjangoではIndex(TemplateView)をあらかじめ用意してくれる。
その為、(TemplateView)を使うときは関数であるdefを使わずclassを使う
結果

class Index(TemplateView):
    template_name = 'myapp/imdex.html'

とすると解消できる

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?