current position:Home>If the HTML page cannot be displayed normally, the code of {% block head%} {% endblock%} will be displayed directly. I don't know what the problem is

If the HTML page cannot be displayed normally, the code of {% block head%} {% endblock%} will be displayed directly. I don't know what the problem is

2022-02-02 22:40:26 CSDN Q & A

As the title

<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css"> <script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script> <script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> <link rel="stylesheet" href="{ 
    { url_for('static',filename='css/base.css') }}"> {% block head %}{% endblock %} <title>{% block title %}{% endblock %}- Zhihu database </title></head><body><nav class="navbar navbar-default"> <div class="container"> <div class="navbar-header"> <img style="width:120px;height:44px" src="{ 
    { url_for('static',filename='images/zhihu6.png') }}" alt=""> <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false"> <span class="sr-only"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> </div> <!-- Collect the nav links, forms, and other content for toggling --> <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> <ul class="nav navbar-nav"> <li class="active"><a href="/"> home page <span class="sr-only">(current)</span></a></li> <li><a href="{ 
    { url_for('question') }}"> Post questions </a></li> </ul> <form class="navbar-form navbar-left" action="{ 
    { url_for('search') }}"> <div class="form-group"> <input name="q" type="text" class="form-control" placeholder=" Please enter keywords "> </div> <button style="background-color:#337ab7;color:#FFFFFF" type="submit" class="btn btn-default"> <span class="glyphicon glyphicon-search" aria-hidden="true"></span> Search </button> </form> <!--<img style="width:400px;height:45px;" src="{ 
    { url_for('static',filename='images/logo4.png') }}" alt="">--> <ul class="nav navbar-nav navbar-right"> {% if username %} <li><a style="color: #0084ff;background: rgba(0,132,255,.1);border-color: transparent;" href="{ 
    { url_for('user',id=0) }}"><span class="glyphicon glyphicon-user" aria-hidden="true"></span> { 
    { 
    username}}</a></li> <li><a href="{ 
    { url_for('logout') }}"><span class="glyphicon glyphicon-remove-sign" aria-hidden="true"></span>  Cancellation </a></li> {% else %} <li><a style="color: #0084ff;background: rgba(0,132,255,.1);border-color: transparent;" href="{ 
    { url_for('login') }}"><span class="glyphicon glyphicon-user" aria-hidden="true"></span>  Sign in </a></li> <li><a href="{ 
    { url_for('regist') }}"><span class="glyphicon glyphicon-plus-sign" aria-hidden="true"></span>  register </a></li> {% endif %} </ul> </div><!-- /.navbar-collapse --> </div><!-- /.container-fluid --></nav><div class="main"> {% block main %}{% endblock %}</div></body></html>



Refer to the answer 1:

The problem is this {% block head %}{% endblock %} Your template doesn't know what it is , It can only be output as a text , At least put it in the label , commonly head It's either a title , keyword , describe ,(js and css introduce ) Besides, I don't know what you mean




Refer to the answer 2:



Refer to the answer 3:

Like Django The template of , The template cannot be accessed directly by double clicking , The source code will be displayed directly , need Django compile , adopt http The required content can only be seen after the protocol accesses the corresponding route




Refer to the answer 4:

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.primo.wiki/2022/02/202202022240236440.html

Random recommended