Как видно из названия, у меня есть проблема, когда отправка не происходит при нажатии кнопки form.submit (Html Публикация также не происходит).
Я предполагаю, что я есть проблема с размещением некоторых тегов, в частности тега.
, прикрепленный ниже, это профиль. html и моя форма из моего froms.py соответственно
{%extends "layout.html"%}
{%block content%}
<!-- Start: Profile Edit Form -->
{{ form.hidden_tag() }}
<div class="container profile profile-view" id="profile" style="border: 1px solid grey;background: rgba(223,248,247,0.42);border-radius: 1rem;padding: 34px;box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);margin-bottom: 32px;margin-top: 32px;">
<form method="POST" action="" enctype="multipart/form-data">
<fieldset class="form-group">
<div class="form-row profile-row" style="margin-right: -5px;">
<div class="col-md-4 relative">
<div class="avatar">
<div class="avatar-bg center" style="background: rgba(223,248,247,0.72);width: 168px;height: 200px;border-radius: 3rem;box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);margin-bottom: 17px;margin-left: 0;"><img src="{{image_file}}" style="width: inherit;height: inherit;margin: 0px;border-radius: inherit;"></div>
</div>
<div class="form-group">
{{ form.picture.label() }}
{{ form.picture(class="form-control", style="padding-top: 3px;") }}
{% if form.picture.errors %}
{% for error in form.picture.errors %}
<span class="text-danger">{{ error }}</span>
{% endfor %}
{% endif %}
</div>
</div>
<div class="col-md-8">
<h1>Profile</h1>
<hr style="margin-bottom: 44px;">
<div class="form-row">
<div class="col-sm-12 col-md-6">
<!-- Start: Username -->
<div class="form-group">
{{ form.username.label(class="form-control-label") }}
{% if form.username.errors %}
{{ form.username(class="form-control form-control-lg is-invalid") }}
<div class="invalid-feedback">
{% for error in form.username.errors %}
<span>{{ error }}</span>
{% endfor %}
</div>
{% else %}
{{ form.username(class="form-control form-control-lg") }}
{% endif %}</div>
<!-- End: Username -->
</div>
</div>
<!-- Start: Email -->
<div class="form-group">
{{ form.email.label(class="form-control-label") }}
{% if form.email.errors %}
{{ form.email(class="form-control form-control-lg is-invalid") }}
<div class="invalid-feedback">
{% for error in form.email.errors %}
<span>{{ error }}</span>
{% endfor %}
</div>
{% else %}
{{ form.email(class="form-control form-control-lg") }}
{% endif %}</div>
<!-- End: Email -->
<div class="form-row">
<div class="col-sm-12 col-md-6">
<!-- Start: Password -->
<div class="form-group">
{{ form.password.label(class="form-control-label") }}
{% if form.password.errors %}
{{ form.password(class="form-control form-control-lg is-invalid") }}
<div class="invalid-feedback">
{% for error in form.password.errors %}
<span>{{ error }}</span>
{% endfor %}
</div>
{% else %}
{{ form.password(class="form-control form-control-lg") }}
{% endif %}</div>
<!-- End: Password -->
</div>
<div class="col-sm-12 col-md-6">
<!-- Start: Confirm Password -->
<div class="form-group">
{{ form.confirm_password.label(class="form-control-label") }}
{% if form.confirm_password.errors %}
{{ form.confirm_password(class="form-control form-control-lg is-invalid") }}
<div class="invalid-feedback">
{% for error in form.confirm_password.errors %}
<span>{{ error }}</span>
{% endfor %}
</div>
{% else %}
{{ form.confirm_password(class="form-control form-control-lg") }}
{% endif %}</div>
<!-- End: Confirm Password -->
</div>
</div>
</fieldset>
<div class="form-row">
<div class="col-md-12 content-right">
<div class="form-group">
{{ form.submit(class="btn btn-primary form-btn", type="submit", style="background-color: rgb(43,172,172);") }}
</div>
<button class="btn btn-danger form-btn" type="reset" style="background-color: rgba(86,198,198,0.81);">CANCEL</button></div>
</div>
</div>
</div>
</form>
</div>
<!-- End: Profile Edit Form -->
{%endblock content %}
my Forms.py форма
class UpdateAccountForm(FlaskForm):
username = StringField('Username',
validators=[DataRequired(), Length(min=2, max=20)])
email = StringField('Email',
validators=[DataRequired(), Email()])
password = PasswordField('Password', validators=[ Length(min=8, max=20)])
confirm_password = PasswordField('Confirm Password',
validators=[ EqualTo('password')])
picture = FileField('Update Profile Picture', validators=[FileAllowed(['jpg', 'png', 'svg'])])
submit = SubmitField('Save')
def validate_username(self, username):
if username.data != current_user.username:
user = User.query.filter_by(username = username.data).first()
if user:
raise ValidationError('Username taken. choose a different one.')
def validate_email(self, email):
if email.data != current_user.email:
user = User.query.filter_by(email = email.data).first()
if user:
raise ValidationError('Email taken. choose a different one.')