I try to create simplest include tag with 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]}
Template test.html:
{% load tegs_test %}
{% test_something %}
{% for i in test_list %}
{{ i }}
{% endfor %}
End I register main in setting.INSTALLED_APPS.
when I try to open test.html getting error:
Caught RuntimeError while rendering: maximum recursion depth exceeded while calling a Python object
Please, help to solve this issue. Thanks.
{% test_something %}calls the templatetest.html, which again calls{% test_something %}and so on…You need to point to a different template withing your tag or use a filter instead.