程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Django - tester lightning protection (django.db.utils.operationalerror: (1054, unknown column user_id in field list))

編輯:Python

As a tester , Use django Linked databases , Are databases created by developers . If the project you are testing is django project , You can skip it without looking , Because your code can directly pull the developed code , To write tests That's all right. .

When we tested , All use reverse generation model The way to create models, Create one-to-one based on the association 、 Foreign keys and many to many , But there's a problem ,django The names of these fields will be created according to their own rules , The field names in our table are probably not named according to this rule .

The error reported above is the error reported by the foreign key Association , The solution many people give is , Let you strictly follow django The naming rules of , Avoid such mistakes . Even as a developer , I want to say : You have your own rules , The company has its own rules , What if the company has other rules ???

The solution is , Use db_column To define the field names in the table ,model The attribute names of are strictly in accordance with django Naming rules for


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved