redirect while passing arguments

后端 未结 4 763
情深已故
情深已故 2020-11-27 15:07

In flask, I can do this:

render_template(\"foo.html\", messages={\'main\':\'hello\'})

And if foo.html contains {{ messages[\'main\']

4条回答
  •  遥遥无期
    2020-11-27 15:54

    I want to mention that url_for cannot be used until it is added to the flask imports!

    I spent an hour trying to find out why it would not work as no one mentioned that in several websites!!!

    Add url_for to the list of imports like this:

    from flask import Flask, render_template, request, redirect, session, url_for
    

提交回复
热议问题