首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >Python Flask儿童模板不渲染

Python Flask儿童模板不渲染
EN

Stack Overflow用户
提问于 2018-09-05 00:48:57
回答 1查看 0关注 0票数 0

基本模板:index.html

儿童模板:child.html

myProject
    templates
        child.html
        index.html
main.py        

当我点击应该呈现child.html的按钮时,没有任何反应。没有错误等。页面保持不变。

index.html部分

<div class="col-lg-9 card mt-5" style="min-height: 750px;">
    <div id="content" class="card-body">
       {% block content %}{% endblock %}
    </div>
</div>

child.html

{% extends "index.html" %}  

{{ super() }} 
{% block content %}   
<h3 id="activeCountry" class="w3-display-topleft w3-text-black w3-container" style="padding:24px 48px">{{activeCountry}}</h3>
<p>Test</p>
{% endblock %}

main.py

@app.route('/setActiveCountry/<item>', methods=['POST'])
def setActiveCountry(item):
    jsdata = request.form['javascript_data']
    print(jsdata)
    return render_template('child.html', activeCountry=jsdata)    

它打印jsdata它到达上面的功能。

我很茫然。我尝试过类似的Stackoverflow问题,但我已经有了他们所缺少的东西。我也尝试取出{{super()}},将“content”作为一个类而不是id,并删除{%sections中的空格。

EN

Stack Overflow用户

发布于 2018-09-05 10:39:03

看来你没有GET请求的处理程序,它会返回任何模板。您的表单路由中应该有一个GET处理程序

@app.route('/', methods=['GET'])
def index():
    return render_template('index.html')

还有一个用于child.html在不同路线下渲染的东西

@app.route('/child', methods=['GET'])
def child():
    return render_template('child.html')

您的问题中也没有任何内容表明对所调用的模板有何用处displayCountryInfo.html

票数 0
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/-100002560

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档