admin管理员组

文章数量:1026728

I can succesfully Upload a file using:

 <form method="post" enctype="multipart/form-data">.

However I can not combine this method with logging in my user.

I want to login my user using the render_form method:

{{ render_form(form, novalidate=True)}}

However, I can't find a way to support uploading a file with this method.

I can succesfully Upload a file using:

 <form method="post" enctype="multipart/form-data">.

However I can not combine this method with logging in my user.

I want to login my user using the render_form method:

{{ render_form(form, novalidate=True)}}

However, I can't find a way to support uploading a file with this method.

Share Improve this question edited Nov 16, 2024 at 22:47 Ahrimann Steiner 1,3441 gold badge11 silver badges31 bronze badges asked Nov 16, 2024 at 16:35 user23568016user23568016 53 bronze badges 1
  • {{ wtf.quick_form(form,enctype="multipart/form-data") }} – Ahrimann Steiner Commented Nov 16, 2024 at 21:03
Add a comment  | 

1 Answer 1

Reset to default 0
    {% macro render_form(form, action) %}
        {% from "_formhelpers.html" import render_field %}
        <div id="Product" class="variant-block" style="display: block;">
            {% from "_formhelpers.html" import render_field %}
            {% import "bootstrap/wtf.html" as wtf %}
            {{ wtf.quick_form(form,enctype="multipart/form-data")  }}
        </div>
    {% endmacro %}

More info. here: https://bootstrap-flask.readthedocs.io/en/stable/macros/

I can succesfully Upload a file using:

 <form method="post" enctype="multipart/form-data">.

However I can not combine this method with logging in my user.

I want to login my user using the render_form method:

{{ render_form(form, novalidate=True)}}

However, I can't find a way to support uploading a file with this method.

I can succesfully Upload a file using:

 <form method="post" enctype="multipart/form-data">.

However I can not combine this method with logging in my user.

I want to login my user using the render_form method:

{{ render_form(form, novalidate=True)}}

However, I can't find a way to support uploading a file with this method.

Share Improve this question edited Nov 16, 2024 at 22:47 Ahrimann Steiner 1,3441 gold badge11 silver badges31 bronze badges asked Nov 16, 2024 at 16:35 user23568016user23568016 53 bronze badges 1
  • {{ wtf.quick_form(form,enctype="multipart/form-data") }} – Ahrimann Steiner Commented Nov 16, 2024 at 21:03
Add a comment  | 

1 Answer 1

Reset to default 0
    {% macro render_form(form, action) %}
        {% from "_formhelpers.html" import render_field %}
        <div id="Product" class="variant-block" style="display: block;">
            {% from "_formhelpers.html" import render_field %}
            {% import "bootstrap/wtf.html" as wtf %}
            {{ wtf.quick_form(form,enctype="multipart/form-data")  }}
        </div>
    {% endmacro %}

More info. here: https://bootstrap-flask.readthedocs.io/en/stable/macros/

本文标签: pythonUpload File with FlaskForm RenderformStack Overflow