我成功地在google cloud上部署了django wagtail网站,但是我得到了:"设置。数据库配置不正确。请提供ENGINE值。查看设置文档了解更多详细信息。错误。我甚至尝试在settings.py中硬编码数据库值,像这样:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'url to sql stuff',
'USER': 'user I register',
'PASSWORD': "my password",
'PORT': '8080',
'HOST': "127.0.0.1"
}
}
我可以确认值是正确的,数据库存在于云上。还是得到相同的错误。我该怎么办?
更新:完整的错误追溯:
Traceback (most recent call last):
File "/layers/google.python.pip/pip/lib/python3.10/site-packages/django/core/handlers/exception.py", line 55, in inner
response = get_response(request)
File "/layers/google.python.pip/pip/lib/python3.10/site-packages/django/core/handlers/base.py", line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/layers/google.python.pip/pip/lib/python3.10/site-packages/wagtail/views.py", line 14, in serve
site = Site.find_for_request(request)
File "/layers/google.python.pip/pip/lib/python3.10/site-packages/wagtail/models/sites.py", line 150, in find_for_request
site = Site._find_for_request(request)
File "/layers/google.python.pip/pip/lib/python3.10/site-packages/wagtail/models/sites.py", line 160, in _find_for_request
site = get_site_for_hostname(hostname, port)
File "/layers/google.python.pip/pip/lib/python3.10/site-packages/wagtail/models/sites.py", line 23, in get_site_for_hostname
sites = list(
File "/layers/google.python.pip/pip/lib/python3.10/site-packages/django/db/models/query.py", line 320, in __iter__
self._fetch_all()
File "/layers/google.python.pip/pip/lib/python3.10/site-packages/django/db/models/query.py", line 1507, in _fetch_all
self._result_cache = list(self._iterable_class(self))
File "/layers/google.python.pip/pip/lib/python3.10/site-packages/django/db/models/query.py", line 57, in __iter__
results = compiler.execute_sql(
File "/layers/google.python.pip/pip/lib/python3.10/site-packages/django/db/models/sql/compiler.py", line 1348, in execute_sql
sql, params = self.as_sql()
File "/layers/google.python.pip/pip/lib/python3.10/site-packages/django/db/models/sql/compiler.py", line 573, in as_sql
extra_select, order_by, group_by = self.pre_sql_setup()
File "/layers/google.python.pip/pip/lib/python3.10/site-packages/django/db/models/sql/compiler.py", line 64, in pre_sql_setup
self.setup_query()
File "/layers/google.python.pip/pip/lib/python3.10/site-packages/django/db/models/sql/compiler.py", line 55, in setup_query
self.select, self.klass_info, self.annotation_col_map = self.get_select()
File "/layers/google.python.pip/pip/lib/python3.10/site-packages/django/db/models/sql/compiler.py", line 284, in get_select
sql, params = self.compile(col)
File "/layers/google.python.pip/pip/lib/python3.10/site-packages/django/db/models/sql/compiler.py", line 496, in compile
sql, params = node.as_sql(self, self.connection)
File "/layers/google.python.pip/pip/lib/python3.10/site-packages/django/db/models/expressions.py", line 948, in as_sql
sql = ".".join(map(compiler.quote_name_unless_alias, identifiers))
File "/layers/google.python.pip/pip/lib/python3.10/site-packages/django/db/models/sql/compiler.py", line 487, in quote_name_unless_alias
r = self.connection.ops.quote_name(name)
File "/layers/google.python.pip/pip/lib/python3.10/site-packages/django/db/backends/dummy/base.py", line 20, in complain
raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.
'NAME': 'url to sql stuff',
'PORT': '8080',
'HOST': "127.0.0.1"
除非你有你有某种隧道设置,以便您的数据库可以通过本地主机访问,我不认为这3个参数是正确的。文档说你可以使用私有IP地址连接到你的数据库,但我不认为他们包括本地主机。postgres的默认端口是5432。name应该是数据库名,而不是url。