django admin配置pymysql.err.InternalError: (1054, “Unknown column ‘sample_curve.id‘ in ‘field list‘“)
阿新 • • 發佈:2021-01-19
技術標籤:SQL & 資料庫
Traceback (most recent call last):
File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/mysql/base.py" , line 101, in execute
return self.cursor.execute(query, args)
File "/app/.heroku/python/lib/python3.6/site-packages/pymysql/cursors.py", line 146, in execute
result = self._query(query)
File "/app/.heroku/python/lib/python3.6/site-packages/pymysql/cursors.py", line 296, in _query
conn.query( q)
File "/app/.heroku/python/lib/python3.6/site-packages/pymysql/connections.py", line 781, in query
self._affected_rows = self._read_query_result(unbuffered=unbuffered)
File "/app/.heroku/python/lib/python3.6/site-packages/pymysql/connections.py", line 942, in _read_query_result
result.read( )
File "/app/.heroku/python/lib/python3.6/site-packages/pymysql/connections.py", line 1138, in read
first_packet = self.connection._read_packet()
File "/app/.heroku/python/lib/python3.6/site-packages/pymysql/connections.py", line 906, in _read_packet
packet.check_error()
File "/app/.heroku/python/lib/python3.6/site-packages/pymysql/connections.py", line 367, in check_error
err.raise_mysql_exception(self._data)
File "/app/.heroku/python/lib/python3.6/site-packages/pymysql/err.py", line 120, in raise_mysql_exception
_check_mysql_exception(errinfo)
File "/app/.heroku/python/lib/python3.6/site-packages/pymysql/err.py", line 115, in _check_mysql_exception
raise InternalError(errno, errorvalue)
pymysql.err.InternalError: (1054, "Unknown column 'sample_curve.id' in 'field list'")
model中欄位是
class SampleCurve(models.Model):
line_id = models.CharField(max_length=128)
sample_set_id = models.IntegerField()
result_table_id = models.CharField(max_length=255)
sample_result_table_id = models.IntegerField()
group_dimension = models.TextField(blank=True, null=True)
properties = models.TextField(blank=True, null=True)
created_by = models.CharField(max_length=50)
created_at = models.DateTimeField()
updated_by = models.CharField(max_length=50)
updated_at = models.DateTimeField()
class Meta:
managed = False
db_table = 'sample_curve'
缺少主鍵,預設是id為主鍵,需要在models.CharField中指定主鍵