我是tryong數據在編輯從數據庫中我得到錯誤的數據update_user_id更多信息,請看看這個鏈接,然後你也會了解請的Django當編輯從數據庫
的http:// www.pastie.org/1301839
我是tryong數據在編輯從數據庫中我得到錯誤的數據update_user_id更多信息,請看看這個鏈接,然後你也會了解請的Django當編輯從數據庫
的http:// www.pastie.org/1301839
您似乎沒有在會話中設置update_user_id
密鑰。通過使用request.session.get
try:
update_user_id = request.session["update_user_id"]
except KeyError:
update_user_id = SOME_DEFAULT_VALUE
或(甚至更好):您可以解決使用異常這個問題
update_user_id = request.session.get("update_user_id", SOME_DEFAULT_VALUE)
兩個片段是等價的。
從您的回溯:
Exception Type: KeyError at /institutes_admin/
Exception Value: 'update_user_id'
一個KeyError異常意味着你試圖用一種並不存在的字典鍵搞定從字典的東西。這看起來像問題(從進一步追溯):
File "/home/karthik/Desktop/EPW_LOCAL/mysite/../mysite/epw/admin_views.py" in institutional_ip_admin
604. update_user_id = request.session['update_user_id']
解決方案將提供一個默認值。
非常感謝你的解決方案它工作正常 – ravi 2010-11-16 08:03:55