我正在构建一个列出艺术家,地点和表演的网络应用。当用户单击列表中的场所时,应将其带到该场所的页面。相反,它只是挂起。它永远不会从场所列表页面移开,浏览器中的加载栏开始加载,但挂起率约为15-20%。没有错误返回,我已经等了几分钟,但它没有动。
我正在发布路线代码,但是如果有必要,您也可以查看Github存储库以获取完整的代码。
@app.route('/venues/<int:venue_id>')
def show_venue(venue_id):
# shows the venue page with the given venue_id
# TODO: replace with real venue data from the venues table, using venue_id
# NOT WORKING YET
# query db for the venue's ID
venuequery = Venue.query.get(venue_id)
# if it finds a venue with that ID
if venuequery:
venue_details = Venue
data = {
"id": venue_details.id,
"name": venue_details.name,
"genres": venue_details.genres,
"addres": venue_details.address,
"city": venue_details.city,
"state": venue_details.state,
"phone": venue_details.phone,
"website": venue_details.website,
"facebook_link": venue_details.facebook_link,
"seeking_talent": venue_details.seeking_talent,
"seeking_description": venue_details.seeking_description,
"image_link": venue_details.image_link,
}
return render_template('pages/show_venue.html', venue=data)
编辑:当我在print(data)
之前添加时,将return
打印以下内容:
{'id': <sqlalchemy.orm.attributes.InstrumentedAttribute object at 0x7f83904780e0>, 'name': <sqlalchemy.orm.attributes.InstrumentedAttribute object at 0x7f8390478180>, 'genres': <sqlalchemy.orm.attributes.InstrumentedAttribute object at 0x7f83904784a0>, 'addres': <sqlalchemy.orm.attributes.InstrumentedAttribute object at 0x7f8390478360>, 'city': <sqlalchemy.orm.attributes.InstrumentedAttribute object at 0x7f8390478220>, 'state': <sqlalchemy.orm.attributes.InstrumentedAttribute object at 0x7f83904782c0>, 'phone': <sqlalchemy.orm.attributes.InstrumentedAttribute object at 0x7f8390478400>, 'website': <sqlalchemy.orm.attributes.InstrumentedAttribute object at 0x7f8390478680>, 'facebook_link': <sqlalchemy.orm.attributes.InstrumentedAttribute object at 0x7f83904785e0>, 'seeking_talent': <sqlalchemy.orm.attributes.InstrumentedAttribute object at 0x7f8390478720>, 'seeking_description': <sqlalchemy.orm.attributes.InstrumentedAttribute object at 0x7f83904787c0>, 'image_link': <sqlalchemy.orm.attributes.InstrumentedAttribute object at 0x7f8390478540>}
用这个
# if it finds a venue with that ID
if venuequery:
venue_details = venuequery # Pass class object instead of class itself
代替这个
# if it finds a venue with that ID
if venuequery:
venue_details = Venue
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句