Python 如何对表单中的一个特定元素执行HTML表单操作

Python 如何对表单中的一个特定元素执行HTML表单操作,python,html,forms,flask,Python,Html,Forms,Flask,我目前正在尝试将上传编码为一个表单,而不是按照flask wtf文档中的示例进行分离,然而HTML表单操作似乎正在将所有表单数据发送到上传文件夹,如下所示。是否有办法使操作仅在上传时执行?先谢谢你 forms.py images = UploadSet('images', IMAGES) class ProductForm(Form): name = StringField('Design', validators=[Required()]) series = Sele

我目前正在尝试将上传编码为一个表单,而不是按照flask wtf文档中的示例进行分离,然而HTML表单操作似乎正在将所有表单数据发送到上传文件夹,如下所示。是否有办法使操作仅在上传时执行?先谢谢你

forms.py    
images = UploadSet('images', IMAGES)

class ProductForm(Form):
    name = StringField('Design', validators=[Required()])
    series = SelectField('Collection', choices=[(c.id, c.name) for c in Series.query.all()], coerce=int)
    material = SelectField('Material', choices=[(c.id, c.name) for c in Material.query.all()], coerce=int)
    purity = SelectField('Purity', choices=[(c.id, c.name) for c in Purity.query.all()], default=['1'], coerce=int)
    description = TextAreaField('Description', validators=[Required()])
    price = IntegerField('Price', validators=[Required()])
    uploads = FileField('Gallery', validators=[FileRequired(), FileAllowed(images, 'Images only!')])
    submit = SubmitField('Add to Display')

views.py
@main.route('/admin/', methods=['GET', 'POST'])
def admin():
    form = ProductForm()
    if form.validate_on_submit():
        artwork = Artwork(name=form.name.data, series_id = form.series.data, material_id = 
        form.material.data, purity_id = form.purity.data, description = form.description.data, price = form.price.data)
        db.session.add(artwork)
        filename = secure_filename(form.uploads.data.filename)
        form.uploads.data.save('app/upload/' + filename)
        flash('The design have been posted.')
    else:
        filename = None
    return render_template('admin.html', form=form, filename=filename)

admin.html
{% block page_content %}
<div class="page-header">
    <h1>Publish your design here</h1>
</div>
{{ wtf.quick_form(form) }}
<form action="/upload/" method="POST" enctype="multipart/form-data">
{{ wtf.quick_form(form) }}
</form>
{% endblock %}

app.config['UPLOAD_FOLDER']=UPLOAD_FOLDER clearlyHi@navanethan,感谢您的回复。这个问题有点不清楚,所以我打开了另一个关于这个问题的帖子,你也参与了!再次感谢你。