[英]syncdb error in django when trying to run python manage.py syncdb
Im Following a django tutorial but I triple checked everything and its no working for me this is what I get.... what did I do wrong. 我正在按照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 ▸▸▸▹▹▹▹▹▹▹
→
This is what I have in DATABASES 这就是我在数据库中拥有的
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
This is models.py
from the app stories
maybe I have something in here im not picking up? 这是来自应用程序stories
models.py
,也许我在这里有东西而不要接听?
from urlparse import urlparse
from django.db import models
from django.contrib.auth.models import User
class Story(models.Model):
title = models.CharField(max_length=200)
url = models.URLField()
points = models.IntergerField()
moderator = models.ForeignKey(User)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
@property
def domain(self):
return urlparse(self.url).netloc
You haven't set the database ENGINE setting in settings.py
您尚未在settings.py
中settings.py
数据库引擎settings.py
This will be created in the same directory than the one from which you run manage.py 这将在与运行manage.py的目录相同的目录中创建。
'NAME': 'data.sqlite',
This will give file name and your location for db 这将提供文件名和您的数据库位置
'NAME': '/yourpath/mysite/data.sqlite',
The best one is to pass an absolute path as 最好的办法是通过一条绝对的道路
import os
SETTINGS_DIR = os.path.dirname(os.path.abspath(__file__))
and NAME as 和NAME作为
'NAME': os.path.join(SETTINGS_DIR, 'data.sqlite'),
In the moderators model I had: 在主持人模型中,我有:
points = models.IntergerField()
and "Inte(r)gerField" does not exist! 和“ Inte(r)gerField”不存在! lol I mistyped it. 大声笑我打错了。 I corrected it to: 我将其更正为:
points = models.IntegerField()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.