include template tag not working in django

前端 未结 4 567
执笔经年
执笔经年 2021-02-14 02:03

My Views.py files looks like below

  def homepage(request):
      template = \'homepage.html\'
      list_display_template = \'list.html\'
      list = model.obj         


        
4条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-14 02:15

    Another situation where an include statement will fail without raising an error is if you are working in a template which extends another, and your include is outside of a named block:

    {% extends "my_base.html" %}
    
    {% block content %}
        {{ block.super }}
        {% include "partials/file1.html" %}
    {% endblock %}
    
    {% include "partials/file2.html" %}
    

    In this case file2.html will not be included because it is not in a block, and you will get no warning messages, and will try all sorts of things before you realise what you've done :-)

提交回复
热议问题