迁移 Django 数据库时天蓝色无效的用户名

azure invalid username when migrating django database

我关注了这个: Tutorial: Deploy a Django web app with PostgreSQL in Azure App Service

我创建了数据库和应用程序,直到:

运行 Django 数据库迁移

在浏览器中打开 SSH 会话,方法是导航至 https://.scm.azurewebsites.net/webssh/host 运行 “python manage.py 迁移”

它给我这个错误

FATAL:  Invalid Username specified. Please check the Username and retry 
connection. The Username should 
be in <username@hostname> format.
(antenv) root@5f4958961a00:/home/site/wwwroot#

我不知道应该把哪个“用户名”改成username@hostname

提前谢谢

当您 create Postgres database in Azure 使用命令时:

az postgres up --resource-group DjangoPostgres-tutorial-rg --location westus2 --sku-name B_Gen5_1 --server-name <postgre-server-name> --database-name pollsdb --admin-user <admin-username> --admin-password <admin-password> --ssl-enforcement Enabled

命令完成后,它会输出一个 JSON 对象,其中包含数据库的不同连接字符串以及服务器 URL、生成的用户名(例如“joyfulKoala@msdocs-djangodb-12345"),以及一个 GUID 密码。

例如,

...
  "host": "postgres-server-name.postgres.database.azure.com",
  "password": "somePassword",
  "username": "wert@postgres-server-name"
}

您可以将上述格式的用户名和密码复制到configure environment variables to connect the database

它对我有效。