AttributeError: 'ForeignKey' object has no attribute 're' 解決辦法


使用

field_object.rel.model.objects.filter(**db_condition)

 

報錯

 

 

forekey中存在rel,為什么不能調用?

 

 

 

 通過以下語句觀察

print(field_object)
print(type(field_object))
print(db_condition)
print(field_object.__dic__)

故:

self.remote_field = rel

 

 sSO 將rel改成remote_field即可

          
field_object.remote_field.model.objects.filter(**db_condition)


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM