I was trying to learn flask and came across the following problem.This is the example that i was trying to implement.
@app.route('/poll', methods = ['GET', 'POST'])
def poll():
form = PollForm()
if form.validate_on_submit():
return render_template('details.html', form = form)
return render_template('poll.html', form=form)
But i wanted to have a different url mapping for details.html, for that purpose i created another route as,
@app.route('/details/<form>')
def details():
return render_template('details.html', form = form):
For using this i have used
return redirect(url_for('details', form=form))
in poll method inside the if condition. And when i tried to access the same from detail.html , i am not able to get it as a object. When tried to replace form with a string, it worked fine. Could you please suggest some mechanism to access form as an object inside the /details route ?
Edit
I was asking something like this is possible.
@app.route('/poll', methods = ['GET', 'POST'])
def poll():
form = PollForm()
if form.validate_on_submit():
@app.route('/details')
return render_template('details.html', form = form)
return render_template('poll.html', form=form)
whenever we get inside the if condition the url will be /poll/details.Or is there any way to make this kind of url nesting, starting from a root url then child urls gets added depending on the business logic.