저는 이것이 Django templating philosophy가 아니라는 것을 알고 있습니다. http 응답 컨텍스트에서 지정한 플러그인 목록에 따라 다른 템플릿을 포함하고 싶습니다. 내가 가진 예를 들어, 다음과 같은 플러그인 구성 :Django Custom 포함 템플릿
{% for custom_plugin in custom_plugins %}
{% include "map/plugins/custom/{{ plugin }}/includes.html" %}
{% endfor %}
나는 또한 시도했다 : :
{% for plugin in plugins %}
@register.inclusion_tag("map/plugins/custom/{{ plugin }}/includes.html", takes_context=True)
{% endfor %}
context['plugins'] = ['weather']
내가 기본 템플릿 파일의 각 템플릿을 포함하려고 현재 각 플러그인에는 include.html 파일에 스크립트 참조 및 CSS 클래스 만 포함됩니다.
<script type="text/javascript" src="{{ MEDIA_URL }}map/js/plugins/custom/weather/weatherStation.js?ver={{ version }}"></script>
의견이 있으십니까?
태그 또는 변수 구문 사용 ** ** 태그 내부는 정확하지 않습니다. –