Я создаю форму для пользователя, чтобы ввести действительный почтовый индекс Великобритании.В настоящее время у меня есть следующий код для формы:
class RegisterForm(Form):
first_name = StringField('First Name', validators=[DataRequired(), validators.Length(min=1, max=50)])
last_name = StringField('Last Name', validators=[DataRequired(), validators.Length(min=1, max=50)])
centre_id = StringField('Centre ID', validators=[DataRequired(), validators.Length(min=1, max=11)])
doctor_id = StringField('Doctor ID', validators=[DataRequired(), validators.Length(min=1, max=11)])
address = StringField('Address Line 1', validators=[DataRequired(), validators.Length(min=1, max=100)])
town_name = StringField('Town Name', validators=[DataRequired(), validators.Length(min=1, max=50)])
county_name = SelectField('County Name', choices=[('antrim', 'Antrim'), ('armagh', 'Armagh'), ('down', 'Down'), ('derry/londonderry', 'Derry/Londonderry'), ('fermanagh', 'Fermanagh'), ('tyrone', 'Tyrone')], validators=[DataRequired()])
postcode = StringField('Postcode', validators=[DataRequired(), validation.is_valid_postcode])
telephone_number = TelField('Telephone Number', validators=[DataRequired(), validators.Length(min=11, max=11)])
email_address = EmailField('Email Address', validators=[DataRequired()])
patient_username = StringField('Username', {validators.DataRequired(), validators.EqualTo('confirm_patient_username', message='Usernames do not match')})
confirm_patient_username = StringField('Confirm Username')
patient_password = PasswordField('Password', {validators.DataRequired(),validators.EqualTo('confirm_patient_password', message='Passwords do not match')})
confirm_patient_password = PasswordField('Confirm Password')
и шаблон:
{% extends 'patient/patient_login_layout.html' %}
{% block body %}
<h1>Patient Register</h1>
{% from 'includes/_formhelpers.html' import render_field %}
<form method="POST" action="">
<div class="form-group">
{{render_field(form.first_name, class="form-control")}}
</div>
<div class="form-group">
{{render_field(form.last_name, class="form-control")}}
</div>
<div class="form-group">
{{render_field(form.centre_id, class="form-control")}}
</div>
<div class="form-group">
{{render_field(form.doctor_id, class="form-control")}}
</div>
<div class="form-group">
{{render_field(form.address, class="form-control")}}
</div>
<div class="form-group">
{{render_field(form.town_name, class="form-control")}}
</div>
<div class="form-group">
{{render_field(form.county_name, class="form-control")}}
</div>
<div class="form-group">
{{render_field(form.postcode, class="form-control")}}
</div>
<div class="form-group">
{{render_field(form.telephone_number, class="form-control")}}
</div>
<div class="form-group">
{{render_field(form.email_address, class="form-control")}}
</div>
<div class="form-group">
{{render_field(form.patient_username, class="form-control")}}
</div>
<div class="form-group">
{{render_field(form.confirm_patient_username, class="form-control")}}
</div>
<div class="form-group">
{{render_field(form.patient_password, class="form-control")}}
</div>
<div class="form-group">
{{render_field(form.confirm_patient_password, class="form-control")}}
</div>
<p><input type="submit" class="btn btn-primary" value="Submit"></p>
</form>
{% endblock %}
, но получаю ошибку: TypeError: аргумент типа 'StringField' не повторяется.
Что я могу сделать, чтобы это исправить?
Редактировать: Вот полная запись формы и шаблон для веб-страницы.Большое спасибо.