テンプレートに、ビューで宣言した変数を渡すやり方をメモします。
テンプレートに値を渡すには、辞書の変数をrender関数の第3引数に入れることで
テンプレートに変数を渡せます。
ビュー
from django.http import HttpResponse
from django.shortcuts import render
def index(request):
message_dict = {'message1':'文字列を渡す', 'message2':'メッセージ2'}
return render(request, 'index.html', message_dict)
テンプレート側で受け取った値を使うには、
{{キーの名前}}で呼び出せます。
テンプレート index.html
<!DOCTYPE html>
<html>
<head>
<title>タイトル</title>
</head>
<body>
{{message1}}
{{message2}}
</body>
</html>
index.htmlの表示結果

上記の結果から、ビューからテンプレートに値が渡せていることがわかります。
