[英]1054, "Unknown column 'work_waterlevel.id' in 'field list'" in django
I am trying to display my mysql data on a HTML page everything is working fine but when i try to display the data from mySQL tohtml page its showing 1054, "Unknown column 'work_waterlevel.id' in 'field list'") this error how要解決此錯誤,我的 models.py 是
from django.db import models
# Create your models here.
class waterlevel(models.Model):
time=models.DateTimeField()
status=models.CharField(max_length=50)
level=models.DecimalField(max_digits=12,decimal_places=6)
回溯如下
File "C:\Users\siddhant\AppData\Local\Programs\Python\Python39\lib\site-packages\django\db\backends\utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
File "C:\Users\siddhant\AppData\Local\Programs\Python\Python39\lib\site-packages\django\db\backends\mysql\base.py", line 73, in execute
return self.cursor.execute(query, args)
File "C:\Users\siddhant\AppData\Local\Programs\Python\Python39\lib\site-packages\MySQLdb\cursors.py", line 206, in execute
res = self._query(query)
File "C:\Users\siddhant\AppData\Local\Programs\Python\Python39\lib\site-packages\MySQLdb\cursors.py", line 319, in _query
db.query(q)
File "C:\Users\siddhant\AppData\Local\Programs\Python\Python39\lib\site-packages\MySQLdb\connections.py", line 259, in query
_mysql.connection.query(self, query)
MySQLdb._exceptions.OperationalError: (1054, "Unknown column 'work_waterlevel.id' in 'field list'")
它顯示我的 view.py 文件中有錯誤我的 view.py 文件如下
def generate(request):
b=request.POST['level']
a=request.POST['status']
output=run([sys.executable,'C:\\Users\\siddhant\\Desktop\\internship\\indicator\\work\\water.py',b,a],stdout=PIPE,text=True)
event_list=waterlevel.objects.all()
return render(request,'result.html',{'event':event_list})
任何人都可以建議我如何將我的 MySQL 數據發送到 result.html 頁面
嘗試這種方式進行修復而無需花費時間:
1 - Delete migrations files
2 - Clean database (delete tables or recreate database)
3 - run makemigration
4 - run migrate
5 - run createsuperuser
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.