我有 Ubuntu 12.10 并在上面安装了 Django。我正在尝试按照http://www.djangoproject.com上的教程进行操作。我正处于运行python manage.py syncdb
命令的位置。下面是回溯。
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 196, in run_from_argv
self.execute(*args, **options.__dict__)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 232, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 371, in handle
return self.handle_noargs(**options)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/syncdb.py", line 57, in handle_noargs
cursor = connection.cursor()
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py", line 306, in cursor
cursor = self.make_debug_cursor(self._cursor())
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/sqlite3/base.py", line 288, in _cursor
self._sqlite_create_connection()
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/sqlite3/base.py", line 257, in _sqlite_create_connection
raise ImproperlyConfigured("Please fill out the database NAME in the settings module before using the database.")
django.core.exceptions.ImproperlyConfigured: Please fill out the database NAME in the settings module before using the database.
以下是我的 settings.py 文件的摘录:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3', 'sqlite3'# Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'NAME': '', # Or path to database file if using sqlite3.
'USER': '', # Not used with sqlite3.
'PASSWORD': '', # 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.
}
}
我做了很多谷歌搜索,并被告知对于 NAME 字段,输入数据库文件的绝对路径。什么是数据库文件,它位于何处?我知道我有sqlite3
。但是,我在任何地方都找不到任何.db
文件。我查看的另一个资源告诉我只需输入任何路径。当我这样做时,我得到一个Cannot open database
错误。任何帮助是极大的赞赏。