2013-04-06 43 views
1

我正在嘗試在Django中檢索頂級投票項目。以下是相關的代碼行:django投票中的錯誤?

originalList = [x[0] for x in list(Vote.objects.get_top(Item, endIdx))[startIdx:]] 

這些索引是用於分頁的目的。當我嘗試在瀏覽器中加載頁面時,我得到:

AttributeError at /items/top/ 
'Settings' object has no attribute 'DATABASE_ENGINE' 

然而,應該尋找的屬性不DATABASE_ENGINE,相反,它是在DATABASES['default']['ENGINE']。這怎麼解決?

回答

0

我已經做了我的猜測是做直到Django的投票最簡單的事情是上游固定如下:

settings.py的結尾,附加:

DATABASE_ENGINE = DATABASES['default']['ENGINE'] 
1

是啊,它看起來就像4 years中沒有觸及的代碼一樣。它聲稱

Note that this application requires Python 2.3 or later, and Django 
0.97-pre or later. You can obtain Python from http://www.python.org/ and 
Django from http://www.djangoproject.com/. 

當時,這很可能是定義數據庫引擎的方式,現在已被棄用。就個人而言,我會避免使用它,也可能有其他問題,以及...