I am trying to understand Python and passing variables. I am trying to pass an id for an 'action'. I can create the action and see the is there but I do not understand how to take the id and pass it from one form to another. If anyone could point me in the right direction would be great.
Views.py
#g.user.nickname passes in the nickname for a refernce
@app.route('/edit', methods=['GET', 'POST'])
@login_required
def edit():
form = EditForm(g.user.nickname)
if form.validate_on_submit():
g.user.nickname = form.nickname.data
g.user.about_me = form.about_me.data
db.session.add(g.user)
db.session.commit()
flash('Your changes have been saved.')
return redirect(url_for('edit'))
elif request.method != "POST":
form.nickname.data = g.user.nickname
form.about_me.data = g.user.about_me
return render_template('edit.html', form=form)
#Don't understand how to create a variable to pass a reference from post.html
@app.route('/action_request', methods=['GET', 'POST'])
@login_required
def action_requests():
form = EditReqForm()
return render_template('action_request.html',
form=form)
Post.html
<table class="table table-hover">
<tr>
<td>
<p>Raised by <a href="{{ url_for('user', nickname=action.author.nickname) }}">{{ action.raised_by }} </a>on
{{ action.date_raised.strftime('%d-%m-%Y') }}:</p>
#Trying to generate reference of action id to pass to ActionReqForm
<p><a href="{{ url_for('action_requests', id=action.id)}}"><strong>
Issue:</strong>{{
action.issue }}</a></p>
<p><strong>Source: {{action.id}}</strong>{{ action.source }}</p>
<p><strong>Immediate Action: </strong>{{ action.immediate_action }}</p>
</td>
</tr>
</table>
找出解决方案request.args.get()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.