Answer the question
In order to leave comments, you need to log in
How to simplify form processing?
def enabled_user():
return User.query
class AddOperationForm(FlaskForm):
email = QuerySelectField(query_factory=enabled_user, get_label='email')
ident = QuerySelectField(query_factory=enabled_user, get_label='ident')
operation = SelectField('Тип операции', coerce=int)
amount = IntegerField('Сумма', validators=[DataRequired()])
# submit = SubmitField('Добавить')
def __init__(self, *args, **kwargs):
super(AddOperationForm, self).__init__(*args, **kwargs)
self.operation.choices = [(op.value, op.name) for op in Operation]
@blueprint.route('/', methods=['GET', 'POST'])
@login_required
def index():
form = AddOperationForm()
return render_template('operation/index.html', form=form)
@blueprint.route('/', methods=['POST'])
@login_required
def add_operation():
form = AddOperationForm(request.???)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question