Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 模板语法错误位于/accounts/profile/_Python_Html_Css_Django_Bootstrap 4 - Fatal编程技术网

Python 模板语法错误位于/accounts/profile/

Python 模板语法错误位于/accounts/profile/,python,html,css,django,bootstrap-4,Python,Html,Css,Django,Bootstrap 4,我有一个错误: TemplateSyntaxError at /accounts/profile/ <ExtendsNode: extends "registration/accounts/base.html"> must be the first tag in the template profile.html是: {% load staticfiles %} {% extends "registration/accounts/base.html" %} {% block con

我有一个错误:

TemplateSyntaxError at /accounts/profile/
<ExtendsNode: extends "registration/accounts/base.html"> must be the first tag in the template
profile.html
是:

{% load staticfiles %}
{% extends "registration/accounts/base.html" %}
{% block content %}
  <html lang="ja">
    <head>
      <meta charset="utf-8">
      <link rel="stylesheet" href="{% static 'bootflat/css/bootflat.min.css' %}">
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    </head>
    <body>

  <a href="{% url 'kenshinresults'%}">SEE YOUR PHOTO</a>

    <div class="container">
      <form action="{% url 'accounts:upload_save' %}" method="POST" enctype="multipart/form-data">
        {% csrf_token %}
        <p>SEND PHOTO</p>
        <input type="file" name="files[]" multiple>
        <input type="hidden" value="{{ p_id }}" name="p_id">
        <input type="submit" value="Upload">
      </form>
    </div>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    </body>
  </html>

{% endblock %}
{%load staticfiles%}
{%extends“registration/accounts/base.html”%}
{%block content%}
  
{%csrf_令牌%}
发送照片

{%endblock%}

我发现只有
base.html
被准确显示,但是当我尝试
base.html
inherit
profile.html
时,发生了这个错误。以前,这两个文件是准确加载的,但当我将
href=“{%static”bootflat/css/bootflat.min.css%%}”
添加到
profile.html
时,发生了此错误。为什么会发生这样的错误?我怎样才能解决这个问题?我认为在profile.html中添加{%load staticfiles%}是正确的,但这是错误的吗?

错误说明必须首先在模板中编写
extends
标记。 您可以在中阅读更多关于此的信息

因此,您应该首先在
profile.html

{% extends "registration/accounts/base.html" %}
{% load staticfiles %}
{% block content %}
  ...
{% endblock %}

之后一切都会好起来的

错误说明您必须首先在模板中写入
extends
标记。 您可以在中阅读更多关于此的信息

因此,您应该首先在
profile.html

{% extends "registration/accounts/base.html" %}
{% load staticfiles %}
{% block content %}
  ...
{% endblock %}

之后一切都会好起来的

> P>您应该将您的<代码> Base.html < /C>文件作为布局和您的代码>配置文件.html 作为该布局内呈现的模板文件。 因此:

  • load staticfiles
    块应该插入到
    base.html
    中,并且应该插入到加载静态资产的每个文件中(参见下一个要点)
  • 当您在
    src=
    中引用静态资产时,就足以使用
    static
    path助手加载它
  • profile.html
    应该扩展布局
    base.html
    ,而
    {%block content%}
    中包含的任何内容都将在正文中的block content标记内呈现
base.html


{%load staticfiles%}
{%block content%}
{%end block%}
profile.html

{%extends“registration/accounts/base.html”%}
{%block content%}
{%csrf_令牌%}
发送照片

{%endblock%}
编辑
正如Daniel Roseman

所说的,你应该把你的<代码> Base.html < /C>文件作为一个布局和你的<代码>配置文件。HTML 作为这个布局内呈现的模板文件。 因此:

  • load staticfiles
    块应该插入到
    base.html
    中,并且应该插入到加载静态资产的每个文件中(参见下一个要点)
  • 当您在
    src=
    中引用静态资产时,就足以使用
    static
    path助手加载它
  • profile.html
    应该扩展布局
    base.html
    ,而
    {%block content%}
    中包含的任何内容都将在正文中的block content标记内呈现
base.html


{%load staticfiles%}
{%block content%}
{%end block%}
profile.html

{%extends“registration/accounts/base.html”%}
{%block content%}
{%csrf_令牌%}
发送照片

{%endblock%}
编辑
正如丹尼尔·罗斯曼(Daniel Roseman)所说,您是否可以在问题中添加您收到的完整回溯错误?您不理解的是什么?错误消息是完全明确的。Extends必须是profile.html中的第一个标记。您可以将收到的完整回溯错误添加到问题中吗?您不理解什么?错误消息是完全明确的。Extends必须是profile.html中的第一个标记。您的评论有点误导。通常,您确实需要在每个子模板中加载模板标记;您之所以不在这里这样做,是因为在子模板中不需要所有HTML。谢谢您的澄清。你想编辑我的答案吗?否则我会编辑它。你的评论有点误导。通常,您确实需要在每个子模板中加载模板标记;您之所以不在这里这样做,是因为在子模板中不需要所有HTML。谢谢您的澄清。你想编辑我的答案吗?否则我会编辑它。
<html lang="ja">
  <head>
    <meta charset="utf-8">
    {% load staticfiles %}
    <link rel="stylesheet" href="{% static 'bootflat/css/bootflat.min.css' %}">
    <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>

  </head>
  <body>
  {% block content %} 
  <!-- your body is fine -->
  {% end block %}
  </body>
</html>
{% extends "registration/accounts/base.html" %}

{% block content %}
    <a href="{% url 'kenshinresults'%}">SEE YOUR PHOTO</a>
    <form action="{% url 'accounts:upload_save' %}" method="POST" enctype="multipart/form-data">
        {% csrf_token %}
        <p>SEND PHOTO</p>
        <input type="file" name="files[]" multiple>
        <input type="hidden" value="{{ p_id }}" name="p_id">
        <input type="submit" value="Upload">
    </form>  
{% endblock %}