私は、inclusion_tag を使用して、最も単純なインクルード タグを作成しようとしています。
\main
\templatetags
\tegs_test.py
\__init__.py
Python tegs_test.py:
from django import template
register = template.Library()
@register.inclusion_tag('test.html')
def test_something():
return {'test_list':[1,2,3,4,5]}
テンプレート test.html:
{% load tegs_test %}
{% test_something %}
{% for i in test_list %}
{{ i }}
{% endfor %}
おわり メインをsetting.INSTALLED_APPSに登録します。test.htmlを開こうとするとエラーが発生します:
レンダリング中に RuntimeError をキャッチしました: Python オブジェクトの呼び出し中に最大再帰深度を超えました
この問題を解決するのを手伝ってください。ありがとう。