0
0

More than 3 years have passed since last update.

Djangoで変数を渡すときメモ

Posted at

テンプレートに値を渡す方法

下記のように辞書形式で渡す。

return TemplateResponse(request, '*****.html',
                        {"変数名": 変数})

引数をhtml内で使用する方法

下記のように記載すれば変数と同様に扱える。

<h1>{{ 変数名 }}</h1>

モデル等複数要素で構成されていれば、下記のように記載すれば同様に変数として扱える。

<h1>{{ 変数名.要素名 }}</h1>
0
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
0
0