Django 编程错误:关系“;账户“U账户”;不存在
我改进了django用户帐户==2.1.0的注册表。在我的本地服务器上一切正常,但在heroku服务器上我看到以下错误:Django 编程错误:关系“;账户“U账户”;不存在,django,django-authentication,Django,Django Authentication,我改进了django用户帐户==2.1.0的注册表。在我的本地服务器上一切正常,但在heroku服务器上我看到以下错误: Django Version: 2.2.6 Exception Type: ProgrammingError Exception Value: relation "account_account" does not exist LINE 1: ...nt"."timezone", "account_account"."language" FROM "account_a
Django Version: 2.2.6
Exception Type: ProgrammingError
Exception Value:
relation "account_account" does not exist
LINE 1: ...nt"."timezone", "account_account"."language" FROM "account_a...
Exception Location: /app/.heroku/python/lib/python3.6/site-packages/django/db/backends/utils.py in _execute, line 84
我删除了数据库并再次进行了迁移/迁移,这没有任何帮助
my settings.py的相关部分:
import dj_database_url
db_config = dj_database_url.config()
if db_config:
DATABASES['default'] = db_config
migrate命令的输出:
Operations to perform:
Apply all migrations: account, admin, auth, contenttypes, sessions, my_apps, sites
Running migrations:
No migrations to apply.
还定义了数据库URL:
heroku config
=== Config Vars
DATABASE_URL: postgres://bvki...longrul
在这里,我尝试获取表“account\u account”:
在sqlite中存在“帐户”\u帐户
但在这个命令的输出中不是迁移“帐户”
它看起来不像是运行了
makemigrations
/migrate
,因为它告诉您该表不存在
(1) 运行makemigrations
和migrate
,并确保在Heroku服务器上运行时使用了正确的设置。
(2) 使用Heroku服务器的设置运行
python manage.py dbshell
,并查看现有的表(\dt
在PostgreSQL中)。account\u account
存在吗?谢谢回复!我补充了我的答案,包括了更多关于你答案的信息。С您是否更详细地描述了(2)点?我如何使用Heroku服务器的设置?嘿@lleviy你解决了吗?我遇到了类似的问题。@Dimanjan是的,我需要在Heroku服务器上进行迁移,而不是在本地服务器上进行迁移。在此之前,我在heroku服务器上的数据库是空的。这个命令解决了我的问题:heroku运行python manage.py进行迁移
>manage.py dbshell
SQLite version 3.30.1 2019-10-10 20:19:45
sqlite> SELECT * FROM "account_account";
1||1|lt
2||2|en
>heroku run python manage.py migrate
Running python manage.py migrate on ⬢ my-app... up, run.5012 (Free)
Operations to perform:
Apply all migrations: admin, auth, contenttypes, sessions, my_app
Running migrations:
No migrations to apply.
Your models have changes that are not yet reflected in a migration, and so won't be applied.
Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.