Home > other >  Flask child templates using the parent template variables
Flask child templates using the parent template variables

Time:09-24

The parent template:
The background to the parent HTML to the student. The username (such as: zhang SAN)

Access to the parent template, are:

And template inherits the navigation bar that part of the parent template, access to the child templates, why doesn't the variables: "Joe"

CodePudding user response:

Can be rendered properly, you should not pass the student in the view

CodePudding user response:

 
@ app. The route ('/base/', the methods=[' GET 'and' POST '])
Def base () :
Student=Student_info. Query. The filter (Student_info. Id==1). The first ()
Return render_template (' base. HTML, student=student)

In the base function view, student to pass into the base. The HTML page template (father), in the children. In HTML, use {% extends' base. HTML '%} inherits the parent template, but shows the student undefined
  • Related