扩展模板工作,但主模板不工作django

扩展模板工作,但主模板不工作django,django,Django,视图.py def base(request): return render(request,"base.html",{'':''}) def index(request): return render(request,"index.html",{'':''}) base.html <html> <head>ppppppppp</head> <body> <h1>this is base tem

视图.py

def base(request):

  return render(request,"base.html",{'':''})

def index(request):

 return render(request,"index.html",{'':''})
base.html

  <html>
    <head>ppppppppp</head>
    <body> 
   <h1>this is base template</h1>
 </body> 
</html>
{% extends "base.html" %}

{% block content %}
 <body>
  <h1>
    Welcome to my app
   </h1>
 </body>`
{% endblock content %}
<html>
    <head>ppppppppp</head>
    <body> 
    {% block content %} {% endblock %}
    </body> 
</html>
{% extends "base.html" %}
{% block content %}
   <h1>Welcome to my app</h1>
{% endblock %}

ppppppppppp
这是基本模板
index.html

  <html>
    <head>ppppppppp</head>
    <body> 
   <h1>this is base template</h1>
 </body> 
</html>
{% extends "base.html" %}

{% block content %}
 <body>
  <h1>
    Welcome to my app
   </h1>
 </body>`
{% endblock content %}
<html>
    <head>ppppppppp</head>
    <body> 
    {% block content %} {% endblock %}
    </body> 
</html>
{% extends "base.html" %}
{% block content %}
   <h1>Welcome to my app</h1>
{% endblock %}
{%extends“base.html”%}
{%block content%}
欢迎使用我的应用程序
`
{%endblock内容%}

这里的问题是django根本无法识别index.html仅显示扩展模板。

这里的正确流程是创建真正的:)基本模板:

base.html

  <html>
    <head>ppppppppp</head>
    <body> 
   <h1>this is base template</h1>
 </body> 
</html>
{% extends "base.html" %}

{% block content %}
 <body>
  <h1>
    Welcome to my app
   </h1>
 </body>`
{% endblock content %}
<html>
    <head>ppppppppp</head>
    <body> 
    {% block content %} {% endblock %}
    </body> 
</html>
{% extends "base.html" %}
{% block content %}
   <h1>Welcome to my app</h1>
{% endblock %}

另外,您不应该像
{%endblock BLOCKNAME%}
那样编写标记,只需
{%endblock%}

这里正确的流程是创建:)基本模板:

base.html

  <html>
    <head>ppppppppp</head>
    <body> 
   <h1>this is base template</h1>
 </body> 
</html>
{% extends "base.html" %}

{% block content %}
 <body>
  <h1>
    Welcome to my app
   </h1>
 </body>`
{% endblock content %}
<html>
    <head>ppppppppp</head>
    <body> 
    {% block content %} {% endblock %}
    </body> 
</html>
{% extends "base.html" %}
{% block content %}
   <h1>Welcome to my app</h1>
{% endblock %}

另外,你不应该像
{%endblock BLOCKNAME%}
那样写标签,只要
{%endblock%}

谢谢你的快速回复,我是django的初学者,所以我对这个主题感到困惑……现在我有了清晰的图片谢谢你的快速回复,我是django的初学者,所以我对这个主题感到困惑……现在我有了清晰的图片