日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

django models索引_django-models – Django模型“IndexError:列表索引超出范围”Pydev

發布時間:2025/4/5 编程问答 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 django models索引_django-models – Django模型“IndexError:列表索引超出范围”Pydev 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

我在

Eclipse PyDev中有一個Django項目.

我有一個文件views.py,其中包含以下行:

from models import ingredient2

在models.py我有:

from django.db import models

class ingredient2(models.Model):

ingredient = models.CharField(max_length=200)

當我嘗試運行該應用程序時,我收到以下錯誤:

File "C:\Python27\lib\site-packages\django\db\models\base.py", line 54, in __new__

kwargs = {"app_label": model_module.__name__.split('.')[-2]}

IndexError: list index out of range

我確實同步了數據庫并啟動了服務器運行.

我進入了base.py并添加了2個打印語句(是的,我可能不應該編輯Django的文件):

if getattr(meta, 'app_label', None) is None:

# Figure out the app_label by looking one level up.

# For 'django.contrib.sites.models', this would be 'sites'.

model_module = sys.modules[new_class.__module__]

print model_module #ADDED

print model_module.__name__ #ADDED

kwargs = {"app_label": model_module.__name__.split('.')[-2]}

他們打印出來:

models

manage.py包含在bolig文件夾中.我認為正確的應用標簽將是“bolig”.該應用程序幾個月前就已經運行了,現在,當我回到它時,有些事情是不對的.我一直在PyDev中創建其他項目.

總結

以上是生活随笔為你收集整理的django models索引_django-models – Django模型“IndexError:列表索引超出范围”Pydev的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。