Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
ビュー ディクショナリからテンプレート ページに渡しました。ディクショナリのサイズが 0 より大きいかどうか、および最初のキーと値のペアを取得するために 0 より大きいかどうかをテンプレート内でチェックする方法は?
{% if some_dict %} Some (k, v) - {{ some_dict.items.0 }} {% endif %}
Python dict は順序付けされていないため、「最初の」kv ペアがないことに注意してください。
そして、テンプレートがこのロジックに適していると確信していますか? 私はそうではありません。