python - Loading different pages under different tabs in flask application -
i want render 3 different pages/views under each tabs.
user.html <ul id="tabs" class="nav nav-tabs" data-tabs="tabs"> <li role="presentation" class="active"><a href="#tab1" data-toggle="tab">edit profile</a></li> <li role="presentation" ><a href="#tab2" data-toggle="tab">change password</a></li> <li role="presentation" ><a href="#tab3" data-toggle="tab">change email</a></li> </ul> <div class="tab-content"> <div class="tab-pane active" id="tab1"> <p>user profile edit</p> </div> <div class="tab-pane" id="tab2"> {% include 'flask_user/change_password.html' %} </div> <div class="tab-pane" id="tab3"> {% include 'change_email.html' %} </div> </div>
and view below:
@app.route('/profile/<int:agent_id>', methods=['get', 'post']) def user_profile(agent_id): form = changepasswordform() if form.validate_on_submit(): change_password() return render_template('user.html', form=form)
currently send 1 form #tab2. if send 3 forms, userprofileform(), changeuseremailform() , changepasswordform() complex while handling post request.
is there other way make work? appreciated.
you don't have post same route 3 forms. set-up 3 different routes handle post backs , set each form's action attribute appropriate route.
Comments
Post a Comment