2

I cannot show a file-upload button. I wrote in profile.html like

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

So,I wrote multipart/form-data tag like

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

But, profile.html did not show the part of ~ .

it showed only {% extends "registration/accounts/base.html" %} ~ {% endblock %}.

How can i fix it?

2
  • 1
    What do you mean by upper and lower? Plus good thing would be to show base.html as well Commented Feb 1, 2017 at 8:51
  • @RajeshYogeshwar thx,ur comments.I added my code info. Commented Feb 1, 2017 at 8:55

1 Answer 1

1

Placing and position of {% block content %} is wrong in your code. There are several issues with your code and I removed them. You dont need an extra {% block body %}. So you should use this code instead :

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

Also Note that, Place the csrf_token in correct position and add value="Upload" to input type="submit" .

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.