【发布时间】:2014-12-06 17:07:22
【问题描述】:
我正在学习 django 和 javascript。我有一个具有以下语法的 json 文件:
{"business_id": "JwUE5GmEO-sH1FuwJgKBlQ", "full_address": "6162 US Highway 51\nDe Forest, WI 53532", "hours": {}, "open": true, "categories": ["Restaurants"], "city": "De Forest", "review_count": 26, "name": "Pine Cone Restaurant", "neighborhoods": [], "longitude": -89.335843999999994, "state": "WI", "stars": 4.0, "latitude": 43.238892999999997, "attributes": {"Take-out": true, "Good For": {"dessert": false, "latenight": false, "lunch": true, "dinner": false, "breakfast": false, "brunch": false}, "Caters": false, "Noise Level": "average", "Takes Reservations": false, "Delivery": false, "Ambience": {"romantic": false, "intimate": false, "touristy": false, "hipster": false, "divey": false, "classy": false, "trendy": false, "upscale": false, "casual": false}, "Parking": {"garage": false, "street": false, "validated": false, "lot": true, "valet": false}, "Has TV": true, "Outdoor Seating": false, "Attire": "casual", "Alcohol": "none", "Waiter Service": true, "Accepts Credit Cards": true, "Good for Kids": true, "Good For Groups": true, "Price Range": 1}, "type": "business"}
我想将它导入 django 数据库。我试过了:
def import_db(request):
f = open('business_out.json', 'r')
for jsonline in f:
#yield json.loads(jsonline)
data = serializers.serialize("json", jsonline)
print data["business_id"]
在localhost://import_db 的这一行出现错误:
data = serializers.serialize("json", jsonline)
Uncaught TypeError: Cannot read property 'key-preview' of undefined klippy.js:163Class.keyup klippy.js:163wrapper.extend.$owner mootools-core.js:1367defn mootools-core.js:3970
【问题讨论】:
-
错误是什么?这对回答您的问题非常有帮助。
标签: python json django postgresql django-views