gpt4 book ai didi

django - 将项目部署到 bitnami 后 django postgresql 数据库中的关系数据库错误

转载 作者:行者123 更新时间:2023-11-29 11:37:34 25 4
gpt4 key购买 nike

我正在使用 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...
^

谢谢你凯蒂

最佳答案

我刚刚将 appname_appname 添加到我的数据库中,它现在可以正常工作了。

抱歉误导 - 我的错误。不过,我仍然不明白为什么这段代码没有被添加到 syncdb 上的数据库中。

但现在一切都很好

关于django - 将项目部署到 bitnami 后 django postgresql 数据库中的关系数据库错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12311363/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com