我正在使用amazon ec2和bitnami-djangostack ami部署我的django项目。
当我在本地开发应用程序时,我使用了mysql。但在部署项目后,我使用了bitnami postgresql的默认值。
现在我收到以下错误:
django.db.utils.DatabaseError: relation "appName_appName" does not exist
LINE 1: SELECT (1) AS "a" FROM "appName_appName" WHERE "appName_a...
^
我不知道数据库为什么两次命名数据库(appName_appName)。
这是完整的终端:
bitnami@dom:/opt/bitnami/projects/Project$ sudo python manage.py syncdb
/opt/bitnami/apps/django/lib/python2.6/site-packages/django/db/__init__.py:60: DeprecationWarning: Short names for ENGINE in database configurations are deprecated. Prepend default.ENGINE with 'django.db.backends.'
DeprecationWarning
/opt/bitnami/projects/Project/cookbook/models.py:94: DeprecationWarning: A Field class whose db_type method hasn't been updated to take a `connection` argument.
class JSONField(models.TextField):
Syncing...
Creating tables ...
Creating table auth_permission
Creating table auth_group_permissions
Creating table auth_group
Creating table auth_user_user_permissions
Creating table auth_user_groups
Creating table auth_user
Creating table auth_message
Creating table django_content_type
Creating table django_session
Creating table django_site
Creating table django_admin_log
Creating table registration_registrationprofile
Creating table south_migrationhistory
You just installed Django's auth system, which means you don't have any superusers defined.
Would you like to create one now? (yes/no): yesa
Please enter either "yes" or "no": yes
Username (Leave blank to use 'root'): xxxx
E-mail address: xxxxx
Password: xxx
Password (again): xxx
Traceback (most recent call last):
File "manage.py", line 14, in <module>
execute_manager(settings)
File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/core/management/__init__.py", line 438, in execute_manager
utility.execute()
File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/core/management/__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/core/management/base.py", line 191, in run_from_argv
self.execute(*args, **options.__dict__)
File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/core/management/base.py", line 220, in execute
output = self.handle(*args, **options)
File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/core/management/base.py", line 351, in handle
return self.handle_noargs(**options)
File "/opt/bitnami/python/lib/python2.6/site-packages/South-0.7.6-py2.6.egg/south/management/commands/syncdb.py", line 90, in handle_noargs
syncdb.Command().execute(**options)
File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/core/management/base.py", line 220, in execute
output = self.handle(*args, **options)
File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/core/management/base.py", line 351, in handle
return self.handle_noargs(**options)
File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/core/management/commands/syncdb.py", line 109, in handle_noargs
emit_post_sync_signal(created_models, verbosity, interactive, db)
File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/core/management/sql.py", line 190, in emit_post_sync_signal
interactive=interactive, db=db)
File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/dispatch/dispatcher.py", line 172, in send
response = receiver(signal=self, sender=sender, **named)
File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/contrib/auth/management/__init__.py", line 70, in create_superuser
call_command("createsuperuser", interactive=True)
File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/core/management/__init__.py", line 166, in call_command
return klass.execute(*args, **defaults)
File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/core/management/base.py", line 220, in execute
output = self.handle(*args, **options)
File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 134, in handle
User.objects.create_superuser(username, email, password)
File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/contrib/auth/models.py", line 140, in create_superuser
u = self.create_user(username, email, password)
File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/contrib/auth/models.py", line 136, in create_user
user.save(using=self._db)
File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/db/models/base.py", line 460, in save
self.save_base(using=using, force_insert=force_insert, force_update=force_update)
File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/db/models/base.py", line 570, in save_base
created=(not record_exists), raw=raw, using=using)
File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/dispatch/dispatcher.py", line 172, in send
response = receiver(signal=self, sender=sender, **named)
File "/opt/bitnami/projects/Project/cookbook/models.py", line 68, in create_cookbook_for_user
if created and not instance.cookbooks.exists():
File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/db/models/manager.py", line 192, in exists
return self.get_query_set().exists(*args, **kwargs)
File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/db/models/query.py", line 496, in exists
return self.query.has_results(using=self.db)
File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/db/models/sql/query.py", line 424, in has_results
return bool(compiler.execute_sql(SINGLE))
File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/db/models/sql/compiler.py", line 735, in execute_sql
cursor.execute(sql, params)
File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/db/backends/util.py", line 34, in execute
return self.cursor.execute(sql, params)
File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/db/backends/postgresql_psycopg2/base.py", line 44, in execute
return self.cursor.execute(query, args)
django.db.utils.DatabaseError: relation "appName_appName" does not exist
LINE 1: SELECT (1) AS "a" FROM "appName_appName" WHERE "appName_a...
^
谢谢你,
凯蒂
答案 0 :(得分:0)
我刚刚将appname_appname添加到我的数据库中,现在工作正常。
抱歉误导 - 我的错误。我仍然不明白为什么这段代码没有被添加到syncdb上的数据库中开始。
但现在一切都很顺利