2013-06-26 36 views
1

我正在使用Nginx - Gunicorn - PostgreSQL和Django。我創建了一個具有用戶完整權限的PostgreSQL數據庫。然後我完成了成功結束的syncdb。我的python manage.py sqlall也給出了結果。但在頁面中,對於我看到的每個模型no such table warning,儘管我可以看到所有成功加載到數據庫中的表。Django PostgreSQL在成功syncdb之後沒有這樣的表錯誤

有沒有什麼我應該在gunicorn-nginx方面做? 有什麼建議嗎?

+1

您是否安裝了'psycopg2'並將''引擎':'django.db.backends.postgresql_psycopg2''放置在settings.py中? – Alp

+0

是'數據庫= { '默認':{ 的 '發動機': 'django.db.backends.postgresql_psycopg2', 'NAME': 「富」, 'USER': '棒', '密碼': '$ foo.bar $', 'HOST':'localhost', 'PORT':'5432', }'我可以在pip freeze中看到psycopg2 == 2.5.1 – tunaktunak

+1

您是否重新啓動gunicorn? – Alp

回答

0

請確保安裝psycopg2和調整DATABASES變量settings.py

DATABASES = { 
    'default': { 
     'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'. 
     'NAME': 'dbname',      # Or path to database file if using sqlite3. 
     'USER': 'dbuser',      # Not used with sqlite3. 
     'PASSWORD': 'dbpass',     # Not used with sqlite3. 
     'HOST': '',        # Set to empty string for localhost. Not used with sqlite3. 
     'PORT': '',        # Set to empty string for default. Not used with sqlite3. 
    } 
} 

另外,確保完成了安裝和配置後重新啓動gunicorn。