我使用django-user-accounts == 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
migrate命令的输出:
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”存在!
但是在此命令的输出中没有迁移“帐户”!
>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.
答案 0 :(得分:0)
您的makemigrations
/ migrate
好像没有运行,因为这告诉您该表不存在。
(1)运行makemigrations
和migrate
,并确保您使用正确的设置运行以在Heroku服务器上运行它。
(2)使用用于Heroku服务器的设置运行python manage.py dbshell
,并查看存在的表(PostgreSQL中的\dt
)。 account_account
是否存在?