尝试运行python manage.py syncdb时django中的syncdb错误

时间:2014-04-12 03:39:29

标签: python django django-models django-syncdb syncdb

我跟随django教程,但我三重检查了一切,它没有为我工作这是我得到的......我做错了什么。

python manage.py syncdb
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/Volumes/SWEETMEDIA/Development/Python/hackernews/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
utility.execute()
  File "/Volumes/SWEETMEDIA/Development/Python/hackernews/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Volumes/SWEETMEDIA/Development/Python/hackernews/lib/python2.7/site-packages/django/core/management/base.py", line 242, in run_from_argv
self.execute(*args, **options.__dict__)
  File "/Volumes/SWEETMEDIA/Development/Python/hackernews/lib/python2.7/site-packages/django/core/management/base.py", line 284, in execute
self.validate()
  File "/Volumes/SWEETMEDIA/Development/Python/hackernews/lib/python2.7/site-packages/django/core/management/base.py", line 310, in validate
num_errors = get_validation_errors(s, app)
  File "/Volumes/SWEETMEDIA/Development/Python/hackernews/lib/python2.7/site-packages/django/core/management/validation.py", line 34, in get_validation_errors
for (app_name, error) in get_app_errors().items():
  File "/Volumes/SWEETMEDIA/Development/Python/hackernews/lib/python2.7/site-packages/django/db/models/loading.py", line 196, in get_app_errors
self._populate()
  File "/Volumes/SWEETMEDIA/Development/Python/hackernews/lib/python2.7/site-packages/django/db/models/loading.py", line 75, in _populate
self.load_app(app_name, True)
  File "/Volumes/SWEETMEDIA/Development/Python/hackernews/lib/python2.7/site-packages/django/db/models/loading.py", line 99, in load_app
models = import_module('%s.models' % app_name)
  File "/Volumes/SWEETMEDIA/Development/Python/hackernews/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module
__import__(name)
  File "/Volumes/SWEETMEDIA/Development/Python/hackernews/hn/stories/models.py", line 6, in <module>
(hackernews)
sweetmedia: /Volumes/SweetMedia/Development/Python/hackernews/hn                                                                                              ▸▸▸▹▹▹▹▹▹▹
→ 

这就是我在DATABASES中所拥有的

 DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}

这是来自应用models.py的{​​{1}},也许我有什么东西在这里我不接受?

stories

2 个答案:

答案 0 :(得分:0)

您尚未在settings.py

中设置数据库引擎设置

这将在与运行manage.py

的目录相同的目录中创建
'NAME': 'data.sqlite',

这将为db

提供文件名和您的位置
'NAME': '/yourpath/mysite/data.sqlite',

最好的方法是传递绝对路径

import os

SETTINGS_DIR = os.path.dirname(os.path.abspath(__file__))

和NAME为

'NAME': os.path.join(SETTINGS_DIR, 'data.sqlite'),

答案 1 :(得分:0)

在主持人模型中,我有:

points = models.IntergerField()

和“Inte(r)gerField”不存在!大声笑我输错了。我把它更正为:

points = models.IntegerField()