最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

python - Upload File with FlaskForm Render_form - Stack Overflow

matteradmin6PV0评论

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/

Post a comment

comment list (0)

  1. No comments so far