首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ProgrammingError:关系"account_account“不存在

ProgrammingError:关系"account_account“不存在
EN

Stack Overflow用户
提问于 2019-11-11 01:45:37
回答 1查看 819关注 0票数 2

我使用django-user-account==2.1.0改进了注册表。在我的本地服务器上一切正常,但在heroku服务器上我看到了以下错误:

代码语言:javascript
复制
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的相关部分:

代码语言:javascript
复制
import dj_database_url
db_config = dj_database_url.config()
if db_config:
    DATABASES['default'] =  db_config

迁移命令的输出:

代码语言:javascript
复制
Operations to perform:
  Apply all migrations: account, admin, auth, contenttypes, sessions, my_apps, sites
Running migrations:
  No migrations to apply.

DATABASE_URL还定义了:

代码语言:javascript
复制
heroku config
=== Config Vars
DATABASE_URL:        postgres://bvki...longrul

这里我尝试获取表"account_account":

代码语言:javascript
复制
>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"!

代码语言:javascript
复制
>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.
EN

回答 1

Stack Overflow用户

发布于 2019-11-11 07:19:29

看起来您的makemigrations / migrate并没有运行,因为它告诉您该表不存在。

(1)运行makemigrationsmigrate,并确保您使用正确的设置在Heroku服务器上运行它。(2)使用您对Heroku服务器的设置运行python manage.py dbshell,并查看存在的表(PostgreSQL中的\dt)。account_account存在吗?

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58791327

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档