[英]Render PostgreSQL cannot translate hostname to address in Django
With Render, I would like to use their free PostgreSQL plan to host my database.使用 Render,我想使用他们的免费 PostgreSQL 计划来托管我的数据库。 I am using Django and I got confused what to use as a HOST.我正在使用 Django,我对使用什么作为主机感到困惑。 The dashboard on Render provides me with an external database url postgres://{given_username_by_render}:******-a.oregon-postgres.render.com/{database_name}
if i use this link as a HOST in the databases settings as Render 上的仪表板为我提供了一个外部数据库 url postgres://{given_username_by_render}:******-a.oregon-postgres.render.com/{database_name}
如果我将此链接用作数据库中的主机设置为
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'name',
'USER': 'username',
'HOST' : 'postgres://{given_username_by_render}:******-a.oregon-postgres.render.com/{database_name}',
'PASSWORD': env('PSGS'),
}
}
I get this error while making migrations.我在进行迁移时遇到此错误。 I had used elephantsql before and they give me a simple host url like tiny.db.elephantsql.com which is plugged in HOST name and it worked but not in this case of using Render我以前用过 elephantsql,他们给了我一个简单的主机 url,比如 tiny.db.elephantsql.com,它插入了 HOST 名称并且有效,但在使用 Render 的情况下无效
RuntimeWarning: Got an error checking a consistent migration history performed for database connection 'default': could not translate host name
"postgres://USER:PASSWORD@EXTERNAL_HOST:PORT/DATABASE"
to address: Unknown server error
My main question is, What do i use as the HOST name in database settings in django?我的主要问题是,我在 Django 的数据库设置中使用什么作为主机名? Or am I doing this all wrong?还是我做错了? If you do not have experience with Render then can you recommend me places where i can learn about things like these?如果您没有使用 Render 的经验,那么您可以向我推荐可以了解这些内容的地方吗?
The host is just ******-a.oregon-postgres.render.com
, everything that comes after @
and before /{database_name}
.主机只是******-a.oregon-postgres.render.com
,在@
之后和/{database_name}
之前的所有内容。
Generally, the URL will have this structure :通常,URL 将具有以下结构:
postgres://{user}:{password}@{host}:{port}/{database}
If you prefer, you could use the URL directly via dj-database-url
.如果您愿意,可以直接通过dj-database-url
使用 URL。 If Render populates the DATABASE_URL
environment variable for you, this library will work right out of the box with very little configuration required.如果 Render 为您填充DATABASE_URL
环境变量,则该库将开箱即用,只需很少的配置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.