繁体   English   中英

将datraframe显示到Django模板中

[英]Display datraframe into django template

我目前正在Django上使用stadistics门户,并且尝试使用以下代码在模板中显示数据Dataframe

View.py:

def tabla(request):
    engine = create_engine('postgresql://postgres:alphabeta@localhost:5432/escaladas')
    t='escalado 08/2017'
    sqltable = ps.read_sql_table(t,engine)
    sqltablehead = sqltable.head(n=10)
    table = sqltablehead.to_html(classes='table',index=False,escape=False)
    return render(request,'escalamiento.html',{'table':table})

我试过在模板上显示带有for表,但什么也没显示,并写了{{table}}但给了我这个https://ibb.co/bVpWw5

有任何想法吗?

请改用{{table|safe}} ,以免HTML 遭到转义

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM