LoginSignup
1
0

More than 5 years have passed since last update.

【Django】context must be a dict rather than tuple Django formsと出たとき

Posted at

はじめに

Django==2.1.3
python==3.6.5
Djangoのviews.pyのrenderメソッドでのエラー

エラーメッセージ

TypeError: context must be a dict rather than tuple.

原因

renderメソッドの第二引数はタプルではない

対策

renderメソッドの第二引数に辞書を渡す

from django.shortcuts import render
##中略##
def hoge(resuest):
    return render(request, 'index.html', ()<==)

ここはこうなる

def hoge(resuest):
    return render(request, 'index.html', {}<==)

感想

TypeErrorで動かね!、どこ!?ってなった人たちに届けばよし。

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