我使用django-user-account==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...
Exception Location: /app/.heroku/python/lib/python3.6/site-packages/django/db/backends/utils.py in _execute, line 84我删除了数据库并再次进行了移民/迁移,但没有任何帮助。
我的settings.py的相关部分:
import dj_database_url
db_config = dj_database_url.config()
if db_config:
DATABASES['default'] = db_config迁移命令的输出:
Operations to perform:
Apply all migrations: account, admin, auth, contenttypes, sessions, my_apps, sites
Running migrations:
No migrations to apply.DATABASE_URL还定义了:
heroku config
=== Config Vars
DATABASE_URL: postgres://bvki...longrul这里我尝试获取表"account_account":
>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在sqlite中存在"account_account“!
但在此命令的输出中不是迁移"account"!
>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.发布于 2019-11-11 07:19:29
看起来您的makemigrations / migrate并没有运行,因为它告诉您该表不存在。
(1)运行makemigrations和migrate,并确保您使用正确的设置在Heroku服务器上运行它。(2)使用您对Heroku服务器的设置运行python manage.py dbshell,并查看存在的表(PostgreSQL中的\dt)。account_account存在吗?
https://stackoverflow.com/questions/58791327
复制相似问题