2017-02-01 16 views
2

ファイルアップロードボタンを表示できません。 は、私は、私は〜profile.htmlは、その一部を示さなかった、ファイルアップロードボタンを表示できません

<form action="{% url 'accounts:upload_save' %}" method="POST" enctype="multipart/form-data">. 

のようなマルチパート/フォームデータタグを書いた。しかし

{% 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> 

ようprofile.htmlに書いています。

{%extends "registration/accounts/base.html"%} 〜{%endblock%}のみが表示されています。

どうすれば修正できますか?

+1

あなたは上下関係をどういう意味ですか?プラス良いことはbase.htmlも表示することです –

+0

@RajeshYogeshwar thx、ur comments.I私のコード情報を追加しました。 – lili

答えて

1

{%ブロックのコンテンツ%}の配置と位置が間違っています。 コードにいくつかの問題があり、それらを削除しました。 余分なものは必要ありません。{%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 %} 

はまた、なお正しい位置にcsrf_tokenを置き、値=への入力タイプは=「を提出する」「アップロード」を追加します。

関連する問題