flask从数据库提取数据有Null值时,页面中会显示为None,请问怎么样才能在页面中显示为空白

html页面图:

图片说明

index.html中相关代码:

<div class="table-responsive">      
<table class="table table-striped table-hover" id="table1" style="table-layout:fixed">
    <thead>
        <tr>
            <th width="16%">域名</th>
            <th width="40%">测试地址</th>
            <th width="30%">网站名称</th>
            <th width="7%">备案号</th>
            <th width="7%">责任区域</th>
        </tr>
    </thead>
    <tbody>
        {% for curr_site in sites %}
        <tr>
        <td style="word-break : break-all; ">{{ curr_site.domain_name }}</td>
        <td style="word-break : break-all; ">{{ curr_site.test_url }}</td>                         
        <td style="word-break : break-all; ">{{ curr_site.site_name }}</td>
        <td style="word-break : break-all; ">{{ curr_site.icp_license }}</td>
        <td style="word-break : break-all; ">{{ curr_site.duty_area }}</td>
        </tr>
        {% endfor %}            
    </tbody>
</table>
</div>

hello.py文件中相关代码:

class cdn_site( db.Model ):
    __tablename__ = 'cdn_site'

    domain_name = db.Column( db.String(180), primary_key=True )
    test_url    = db.Column( db.String(1000) )
    site_name   = db.Column( db.String(1000) )
    icp_license = db.Column( db.String(1000) )
    duty_area   = db.Column( db.String(10) )
    sno_customer= db.Column( db.Integer )   

@app.route('/',methods=['GET','POST'])
def index():
    page = request.args.get('page',1,type=int)
    pagination = cdn_site.query.order_by( db.asc(cdn_site.domain_name) ).paginate(page,10,False)
    site_list = pagination.items

    return render_template( "index.html",sites=site_list,pagination=pagination)

1个回答

用空字符串" "代替None

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问