【问题标题】:Django ValueError 'accounts.user', but app 'accounts' isn't installedDjango ValueError 'accounts.user',但未安装应用程序'accounts'
【发布时间】:2019-04-19 10:15:52
【问题描述】:

几天我写了一个应用程序来扩展用户模型,它很简单而且很好用。稍后我推送到 GitHub 并从我的本地机器中删除。

现在我已经将该应用程序再次克隆到我的机器并尝试迁移和运行服务器,但它返回此错误:

ValueError: The field admin.LogEntry.user was declared with a lazy reference to 'accounts.user', but app 'accounts' isn't installed.

我已安装的应用:

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'accountsapp'
]

我不知道项目的应用名称 accounts 这是我见过的非常奇怪的错误。

如果你想看我的整个项目,去那里:

Porjects on Github, click here to see

你会看到这个应用程序是多么简单。

即使我删除了 previos db 文件、pychch、迁移历史记录等,也不知道为什么它不起作用

【问题讨论】:

    标签: django django-models django-forms


    【解决方案1】:

    您的项目中没有迁移。所以没有创建MyUser 的表。您需要先进行迁移并运行它们。

    python manage.py makemigrations
    python manage.py migrate
    

    这会解决你的问题

    【讨论】:

    • 这就是我已经说过的,我什至不能迁移或迁移,它会返回同样的错误,你可以尝试从 github 克隆我的项目
    • 尝试在您的INSTALLED_APPS 中添加accounts
    • 尝试在没有 AUTH_USER_MODEL 设置的情况下进行迁移。另外,结帐stackoverflow.com/questions/47059198/…
    猜你喜欢
    • 2019-05-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-19
    • 2021-04-18
    • 2016-01-02
    • 1970-01-01
    相关资源
    最近更新 更多