我有一个问题,为了解决它,我尝试进入 shell,但我找不到解决方案,所以我希望你能帮助我。我正在导入包含 id 和图像 URL 的模型图像,但由于此错误我无法获取它。代码:
from recipes_database.models import Images
Images.objects.all()
这里是错误:
Traceback (most recent call last): File "F:\Developement\Projects\WhatToCookWeb\venv\lib\site-packages\django\db\backends\utils.py", line 84, in _execute
return self.cursor.execute(sql, params) File "F:\Developement\Projects\WhatToCookWeb\venv\lib\site-packages\django\db\backends\sqlite3\base.py", line 413, in execute
return Database.Cursor.execute(self, query, params) sqlite3.OperationalError: no such column: Images.id
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "<console>", line 1, in <module> File "F:\Developement\Projects\WhatToCookWeb\venv\lib\site-packages\django\db\models\query.py", line 263, in __repr__
data = list(self[:REPR_OUTPUT_SIZE + 1]) File "F:\Developement\Projects\WhatToCookWeb\venv\lib\site-packages\django\db\models\query.py", line 269, in __len__
self._fetch_all() File "F:\Developement\Projects\WhatToCookWeb\venv\lib\site-packages\django\db\models\query.py", line 1303, in _fetch_all但是当我对其他模型做同样的事情时,它起作用了,我想知道这次有什么不同。这是我的图像模型:
class Images(models.Model):
# Field name made lowercase.
rezept_id = models.ForeignKey(
'Rezepte', models.DO_NOTHING, db_column='Rezept_ID', blank=True, null=True)
# Field name made lowercase.
image_url = models.CharField(
db_column='Image_URL', blank=True, null=True, max_length=1000)
class Meta:
managed = False
db_table = 'Images'
我认为 Django 以某种方式使用了错误的查询,因为没有 Images.id,只有 Images.recipe_id。希望你能帮助我谢谢!
吃鸡游戏
相关分类