Django教程 - 数据库设置 - sqlite3(Stuck ..)

时间:2013-01-22 11:46:01

标签: django sqlite django-settings syncdb

所以,我是Django教程'编写你的第一个Django应用程序,第1部分'中的here(数据库设置)。到目前为止,一切都很顺利,但现在我被卡住了。

我进入DOS的外部mysite目录,然后输入'edit settings.py'。这将在外部mysite目录中创建一个名为“settings.py”的新文件,并打开一个完全为空的蓝色DOS文本编辑器框。在这个盒子里,我尝试输入各种东西,保存并退出。如果我再次输入edit settings.py,则保存的文本仍然存在,应该是。

我无法复制或粘贴到这个蓝色的DOS文本编辑器,所以我必须在那里输入所有内容,现在在这里,手动输入。

我目前在mysite / settings.py中有这个(虽然,我尝试过多种方式输入信息,例如'django.db.backends.sqlite3'代表引擎,并输入'DATABASE_ENGINE'等...

DATABASES = {
    'default' : {
        'ENGINE' = 'C:\Django-1.4.3\Django-1.4.3\django\db\backends\sqlite3',
        'NAME' = 'C:\DOCUMENTS and settings\Miles\My Documents\DjangoExperimentation\mysite\sqlite3.db',
        'TIMEZONE' = 'Europe/London'
    }
}

保存并退出,然后输入'python manage.py syncdb',我收到的消息,谢天谢地我可以在主DOS窗口中复制,如下:

C:\DOCUME~1\Miles\MYDOCU~1\DJANGO~1\mysite>python manage.py syncdb
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line
443, in execute_from_command_line
    utility.execute()
  File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line
382, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Python27\lib\site-packages\django\core\management\base.py", line 196,
 in run_from_argv
    self.execute(*args, **options.__dict__)
  File "C:\Python27\lib\site-packages\django\core\management\base.py", line 232,
 in execute
    output = self.handle(*args, **options)
  File "C:\Python27\lib\site-packages\django\core\management\base.py", line 371,
 in handle
    return self.handle_noargs(**options)
  File "C:\Python27\lib\site-packages\django\core\management\commands\syncdb.py"
, line 57, in handle_noargs
    cursor = connection.cursor()
  File "C:\Python27\lib\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 co
nfigured. Please supply the ENGINE value. Check settings documentation for more
details.

(顺便说一下......在stackoverflow中,有没有办法将标记为代码而不单独缩进每一行? - 我已经计算出复制/粘贴四个空格了)

所以,请帮忙..拜托?我在这里做错了什么?

这是整个'djangoExperimentation'目录的读数,我正在尝试这样做:

C:\DOCUME~1\Miles\MYDOCU~1\DJANGO~1>dir /s
 Volume in drive C has no label.
 Volume Serial Number is 30A4-7E91

 Directory of C:\DOCUME~1\Miles\MYDOCU~1\DJANGO~1

21/01/2013  15:42    <DIR>          .
21/01/2013  15:42    <DIR>          ..
22/01/2013  11:36    <DIR>          mysite
               0 File(s)              0 bytes

 Directory of C:\DOCUME~1\Miles\MYDOCU~1\DJANGO~1\mysite

22/01/2013  11:36    <DIR>          .
22/01/2013  11:36    <DIR>          ..
21/01/2013  15:42               259 manage.py
21/01/2013  17:42    <DIR>          mysite
22/01/2013  11:36               268 settings.py
               2 File(s)            527 bytes

 Directory of C:\DOCUME~1\Miles\MYDOCU~1\DJANGO~1\mysite\mysite

21/01/2013  17:42    <DIR>          .
21/01/2013  17:42    <DIR>          ..
21/01/2013  15:42             5,363 settings.py
21/01/2013  17:42             2,837 settings.pyc
21/01/2013  15:42               573 urls.py
21/01/2013  17:42               286 urls.pyc
21/01/2013  15:42             1,162 wsgi.py
21/01/2013  17:42             1,042 wsgi.pyc
21/01/2013  15:42                 0 __init__.py
21/01/2013  17:42               148 __init__.pyc
               8 File(s)         11,411 bytes

     Total Files Listed:
              10 File(s)         11,938 bytes
               8 Dir(s)  10,776,023,040 bytes free

所有帮助都将受到热切期待和赞赏,

谢谢,

数。

3 个答案:

答案 0 :(得分:3)

我猜您的问题是数据库设置中应该没有TIMEZONE密钥。如果要设置时区,请将其添加为DATABASES定义之外的变量,如下所示:

DATABASES = {
    'default' : {
        'ENGINE' = 'django.db.backends.sqlite3',
        'NAME' = 'C:\DOCUMENTS and settings\Miles\My Documents\DjangoExperimentation\mysite\sqlite3.db',
    }
}
TIME_ZONE = 'Europe/London'

答案 1 :(得分:1)

尝试更换 'ENGINE' = 'C:\Django-1.4.3\Django-1.4.3\django\db\backends\sqlite3',

使用:

'ENGINE' = 'django.db.backends.sqlite3',

答案 2 :(得分:0)

“指定路径时,总是使用正斜杠,即使在Windows上(例如C:/homes/user/mysite/sqlite3.db)。”

https://docs.djangoproject.com/en/1.5/intro/tutorial01/