Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.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 我无法显示文件上载按钮_Python_Html_Django - Fatal编程技术网

Python 我无法显示文件上载按钮

Python 我无法显示文件上载按钮,python,html,django,Python,Html,Django,我无法显示文件上载按钮。 我在profile.html中像 {% extends "registration/accounts/base.html" %} {% block content %} user.username: {{ user.username }}<hr> user.is_staff: {{ user.is_staff }}<hr> user.is_active: {{ user.is_active }}<hr> user.last_login

我无法显示文件上载按钮。 我在profile.html中像

{% extends "registration/accounts/base.html" %}
{% block content %}
user.username: {{ user.username }}<hr>
user.is_staff: {{ user.is_staff }}<hr>
user.is_active: {{ user.is_active }}<hr>
user.last_login: {{ user.last_login }}<hr>
user.date_joined: {{ user.date_joined }}
{% endblock %}

<!DOCTYPE html>
<html lang="ja">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <title>UPLOAD</title>


    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <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>
    <![endif]-->
  </head>
  <body>

{% block body %}
<div class="container">
  <form action="{% url 'accounts:upload_save' %}" method="POST" enctype="multipart/form-data">
    <input type="file" name="files[]" multiple>
    <input type="hidden" value="{{ p_id }}" name="p_id">
    {% csrf_token %}
    <input type="submit">
  </form>
</div>
{% endblock %}

   <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>


  </body>
</html>
{%extends“registration/accounts/base.html”%}
{%block content%}
user.username:{{user.username}}
user.is_staff:{{user.is_staff}}
user.is_active:{{user.is_active}}
user.last_login:{{user.last_login}}
user.date_joined:{{user.date_joined} {%endblock%} 上传 {%block body%} {%csrf_令牌%} {%endblock%}
因此,我编写了multipart/form数据标记,如

 <form action="{% url 'accounts:upload_save' %}" method="POST" enctype="multipart/form-data">.
但是,profile.html没有显示~

它只显示了{%extends“registration/accounts/base.html”%} ~{%endblock%}


如何修复它?

代码中{%block content%}的放置和位置错误。 你的代码有几个问题,我删除了它们。 您不需要额外的{%block body%}。 因此,您应该使用以下代码:

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

  <!DOCTYPE html>

  <html lang="ja">
    <head>
      <meta charset="utf-8">
      <meta http-equiv="X-UA-Compatible" content="IE=edge">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <title>UPLOAD</title>
    </head>
    <body>
    user.username: {{ user.username }}<hr>
    user.is_staff: {{ user.is_staff }}<hr>
    user.is_active: {{ user.is_active }}<hr>
    user.last_login: {{ user.last_login }}<hr>
    user.date_joined: {{ user.date_joined }}

    <div class="container">
      <form action="{% url 'accounts:upload_save' %}" method="POST" enctype="multipart/form-data">
        {% csrf_token %}
        <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 %}
{%extends“registration/accounts/base.html”%}
{%block content%}
上传
user.username:{{user.username}}
user.is_staff:{{user.is_staff}}
user.is_active:{{user.is_active}}
user.last_login:{{user.last_login}}
user.date_joined:{{user.date_joined} {%csrf_令牌%} {%endblock%}

还要注意的是,将csrf_令牌放置在正确的位置,并将value=“Upload”添加到input type=“submit”

您所说的上限和下限是什么意思?另外,最好将base.html显示为well@RajeshYogeshwar谢谢,你的评论。我添加了我的代码信息。