2017-03-05 89 views
-1
t_cat_id = t_cat.id 
cursor.execute("select offered_item,offered_item_category_id from foundation_swaptable where accepted_item = %s", t_cat.id) 

上面的代碼拋出下面的異常:django的 - 「INT」對象沒有屬性「鍵」

「INT」對象沒有屬性「關鍵字」

當我包圍t_cat.id與方括號如下:

cursor.execute("select offered_item,offered_item_category_id from foundation_swaptable where accepted_item = %s", [t_cat.id]) 

錯誤消失。

其中t_cat是MPTT類對象,其餘如下取:

MpttCategory.objects.get(category_name=t_category) 

並且它具有在DB表示的ID列是整數。

誰能告訴我爲什麼我得到這個例外。我無法將錯誤的含義與錯誤聯繫起來。 請告訴我是否需要更多信息..

ps。我有點醉了:)

回答

相關問題