让我进一步阐明我想要做的事情。我一直在我的机器上开发我的Django项目。我也将代码检查到一个存储库中。目前我是唯一的开发者,但其他开发者将加入。他们将从存储库检出代码并在其机器上运行它。为了模拟这种情况,我检查了我的代码到另一个目录并创建了一个新的数据库。我更新了checkout的settings.py以使用新的数据库。当我执行syncdb重新创建表,我得到这个错误:Django:重新创建表格
User Host Type Privileges Grant Action
root localhost global ALL PRIVILEGES Yes Edit Privileges
,并从settings.py:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'testproj', # Or path to database file if using sqlite3.
# The following settings are not used with sqlite3:
'USER': 'root',
'PASSWORD': '****',
'HOST': '127.0.0.1', # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP.
'PORT': '', # Set to empty string for default.
}
}
这里是
$ python -i manage.py syncdb
DatabaseError: (1146, "Table 'testproj.auth_user' doesn't exist")
Traceback (most recent call last):
File "manage.py", line 13, in <module>
execute_from_command_line(sys.argv)
File "c:\Users\jpp\Documents\.virtualenvs\django-test\lib\site-packages\dja
ngo\core\management\__init__.py", line 453, in execute_from_command_line
utility.execute()
File "c:\Users\jpp\Documents\.virtualenvs\django-test\lib\site-packages\dja
ngo\core\management\__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "c:\Users\jpp\Documents\.virtualenvs\django-test\lib\site-packages\dja
ngo\core\management\base.py", line 230, in run_from_argv
sys.exit(1)
SystemExit: 1
这里从phymyadmin是我的数据库设置INSTALLED_APPS:
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
# Uncomment the next line to enable the admin:
# 'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
'helloworld',
)
因此,我怀疑另一个开发者有这个相同的问题。这是以前必须解决的情况,但我还没有能够将Google的正确词汇放在一起。
请显示完整的回溯,也是您的数据库设置(不要忘记在显示给我们之前更改数据库的密码) – 2013-05-14 03:52:27
保持HOST也为空。还请显示setup.py的installed_apps – 2013-05-14 06:39:53
好的,当我这样做时,出现此错误:'OperationalError:(2003,“无法连接到'localhost'(10061)”)上的MySQL服务器''。但是,我一直使用HOST作为127.0.0.1成功用于我的其他项目;本地主机不适合我。 – user2233706 2013-05-14 12:03:59