2013-02-26 43 views
1

我是Heroku/Django/Postgres遊戲的新手,並且按照其tutorial中的說明操作後遇到問題。這裏是我的設置:Heroku Django安裝後postgres數據庫/ syncdb的問題

安裝: Django的1.4.5 dj_database_url Postgress.app 9.2.2.0

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

,後來:

import dj_database_url 
    DATABASES['default'] = dj_database_url.config() 

當我運行python manage.py syncdb:

Traceback (most recent call last): 
    File "manage.py", line 10, in <module> 
    execute_from_command_line(sys.argv) 
    File "/Users/joerobinson/.virtualenvs/dg/lib/python2.7/site-   packages/django/core/management/__init__.py", line 443, in execute_from_command_line 
utility.execute() 
    File "/Users/joerobinson/.virtualenvs/dg/lib/python2.7/site-packages/django/core/management/__init__.py", line 382, in execute 
self.fetch_command(subcommand).run_from_argv(self.argv) 
    File "/Users/joerobinson/.virtualenvs/dg/lib/python2.7/site-packages/django/core/management/base.py", line 196, in run_from_argv 
self.execute(*args, **options.__dict__) 
    File "/Users/joerobinson/.virtualenvs/dg/lib/python2.7/site-packages/django/core/management/base.py", line 232, in execute 
output = self.handle(*args, **options) 
    File "/Users/joerobinson/.virtualenvs/dg/lib/python2.7/site-packages/django/core/management/base.py", line 371, in handle 
return self.handle_noargs(**options) 
    File "/Users/joerobinson/.virtualenvs/dg/lib/python2.7/site-packages/django/core/management/commands/syncdb.py", line 57, in handle_noargs 
cursor = connection.cursor() 
    File "/Users/joerobinson/.virtualenvs/dg/lib/python2.7/site-packages/django/db/backends/dummy/base.py", line 15, in complain 
raise ImproperlyConfigured("settings.DATABASES is improperly configured. " 
django.core.exceptions.ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details. 

當我運行python manage.py殼,導入設置,並查看數據庫,我得到:

{'default': {'ENGINE': 'django.db.backends.dummy', 'TEST_MIRROR': None, 'NAME': '', 'TEST_CHARSET': None, 'TIME_ZONE': 'UTC', 'TEST_COLLATION': None, 'PORT': '', 'HOST': '', 'USER': '', 'TEST_NAME': None, 'PASSWORD': 

所以我知道我必須配置不當的東西,但我還沒有發現在一夜間正確的設置搜索。任何人見過這個?

回答

0

我只好點配置數據庫網址如下:

DATABASES['default'] = dj_database_url.config(default='postgres://localhost/db_name') 

我不得不與該psycopg2包和gcc-4.2等問題,但這些都是不屬於我的原來的帖子。

1

您可能想要一個真正的Django數據庫後端,而不是django.db.backends.dummy。例如:

{'ENGINE': 'django.db.backends.postgresql_psycopg2', ... } 
+0

是的,我肯定希望如此。問題是我不確定django.db.backends.dummy插入的位置。必須是這一行:DATABASES ['default'] = dj_database_url.config()。我如何給dj_database_url.config()設置上面的數據庫默認值? – Joe 2013-02-26 18:36:00

+0

@Joe啊,好的。抱歉。可能http://stackoverflow.com/a/3249215/398670或http://stackoverflow.com/questions/2947618/django-tutorial-says-i-havent-set-database-engine-setting-yet-but-i - 有? – 2013-02-27 00:05:30

0

我刪除虛擬/ base.py和創建符號鏈接到它解決了同樣的問題:

ln -s /usr/lib/python2.6/site-packages/django/db/backends/sqlite3/base.py /usr/lib/python2.6/site-packages/django/db/backends/dummy/base.py