- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
如果我的代码中有任何错误(在使用 LoginRequiredMixin 的 View 中使用的模型中的代码),例如一个错误,如:
if (True: # <-- example bug to show how bugs like this are hidden
"AUTH_USER_MODEL refers to model '%s' that has not been installed" % settings.AUTH_USER_MODEL
django.core.exceptions.ImproperlyConfigured:
AUTH_USER_MODEL refers to model 'auth.User' that has not been installed
from django.contrib.auth.mixins import LoginRequiredMixin
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth', # <-- Important for this topic!
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'myapp.apps.CommonConfig',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
from django.contrib import auth
from django.contrib.auth.models import User
Traceback (most recent call last):
File "C:\Users\User\.virtualenvs\myproject-wc-xNQPL\lib\site-packages\django\apps\registry.py", line 155, in get_app_config
return self.app_configs[app_label]
KeyError: 'auth'
C:\code\myproject\src>pipenv run python manage.py makemigrations
Traceback (most recent call last):
File "manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\User\.virtualenvs\myproject-wc-xNQPL\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
utility.execute()
File "C:\Users\User\.virtualenvs\myproject-wc-xNQPL\lib\site-packages\django\core\management\__init__.py", line 357, in execute
django.setup()
File "C:\Users\User\.virtualenvs\myproject-wc-xNQPL\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\User\.virtualenvs\myproject-wc-xNQPL\lib\site-packages\django\apps\registry.py", line 114, in populate
app_config.import_models()
File "C:\Users\User\.virtualenvs\myproject-wc-xNQPL\lib\site-packages\django\apps\config.py", line 211, in import_models
self.models_module = import_module(models_module_name)
File "C:\Users\User\.virtualenvs\myproject-wc-xNQPL\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\code\myproject\src\myapp\models.py", line 14, in <module>
from .sql import myapp_entry_clean, myapp_entry_grouping
File "C:\code\myproject\src\myapp\sql.py", line 68
if (True:
^
SyntaxError: invalid syntax
C:\code\myproject\src>
C:\code\myproject\src>pipenv run python manage.py runserver
Watching for file changes with StatReloader
Exception in thread Thread-1:
Traceback (most recent call last):
File "C:\Users\User\AppData\Local\Programs\Python\Python36\Lib\threading.py", line 916, in _bootstrap_inner
self.run()
File "C:\Users\User\AppData\Local\Programs\Python\Python36\Lib\threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\User\.virtualenvs\myproject-wc-xNQPL\lib\site-packages\django\utils\autoreload.py", line 54, in wrapper
fn(*args, **kwargs)
File "C:\Users\User\.virtualenvs\myproject-wc-xNQPL\lib\site-packages\django\core\management\commands\runserver.py", line 109, in inner_run
autoreload.raise_last_exception()
File "C:\Users\User\.virtualenvs\myproject-wc-xNQPL\lib\site-packages\django\utils\autoreload.py", line 77, in raise_last_exception
raise _exception[0](_exception[1]).with_traceback(_exception[2])
File "C:\Users\User\.virtualenvs\myproject-wc-xNQPL\lib\site-packages\django\utils\autoreload.py", line 54, in wrapper
fn(*args, **kwargs)
File "C:\Users\User\.virtualenvs\myproject-wc-xNQPL\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\User\.virtualenvs\myproject-wc-xNQPL\lib\site-packages\django\apps\registry.py", line 114, in populate
app_config.import_models()
File "C:\Users\User\.virtualenvs\myproject-wc-xNQPL\lib\site-packages\django\apps\config.py", line 211, in import_models
self.models_module = import_module(models_module_name)
File "C:\Users\User\.virtualenvs\myproject-wc-xNQPL\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\code\myproject\src\myapp\models.py", line 14, in <module>
from .sql import myapp_entry_clean, myapp_entry_grouping
File "<string>", line None
SyntaxError: invalid syntax (sql.py, line 68)
Traceback (most recent call last):
File "C:\Users\User\.virtualenvs\myproject-wc-xNQPL\lib\site-packages\django\apps\registry.py", line 155, in get_app_config
return self.app_configs[app_label]
KeyError: 'auth'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\User\.virtualenvs\myproject-wc-xNQPL\lib\site-packages\django\contrib\auth\__init__.py", line 165, in get_user_model
return django_apps.get_model(settings.AUTH_USER_MODEL, require_ready=False)
File "C:\Users\User\.virtualenvs\myproject-wc-xNQPL\lib\site-packages\django\apps\registry.py", line 205, in get_model
app_config = self.get_app_config(app_label)
File "C:\Users\User\.virtualenvs\myproject-wc-xNQPL\lib\site-packages\django\apps\registry.py", line 162, in get_app_config
raise LookupError(message)
LookupError: No installed app with label 'auth'.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\User\.virtualenvs\myproject-wc-xNQPL\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
utility.execute()
File "C:\Users\User\.virtualenvs\myproject-wc-xNQPL\lib\site-packages\django\core\management\__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\User\.virtualenvs\myproject-wc-xNQPL\lib\site-packages\django\core\management\base.py", line 323, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\User\.virtualenvs\myproject-wc-xNQPL\lib\site-packages\django\core\management\commands\runserver.py", line 60, in execute
super().execute(*args, **options)
File "C:\Users\User\.virtualenvs\myproject-wc-xNQPL\lib\site-packages\django\core\management\base.py", line 364, in execute
output = self.handle(*args, **options)
File "C:\Users\User\.virtualenvs\myproject-wc-xNQPL\lib\site-packages\django\core\management\commands\runserver.py", line 95, in handle
self.run(**options)
File "C:\Users\User\.virtualenvs\myproject-wc-xNQPL\lib\site-packages\django\core\management\commands\runserver.py", line 102, in run
autoreload.run_with_reloader(self.inner_run, **options)
File "C:\Users\User\.virtualenvs\myproject-wc-xNQPL\lib\site-packages\django\utils\autoreload.py", line 579, in run_with_reloader
start_django(reloader, main_func, *args, **kwargs)
File "C:\Users\User\.virtualenvs\myproject-wc-xNQPL\lib\site-packages\django\utils\autoreload.py", line 564, in start_django
reloader.run(django_main_thread)
File "C:\Users\User\.virtualenvs\myproject-wc-xNQPL\lib\site-packages\django\utils\autoreload.py", line 272, in run
get_resolver().urlconf_module
File "C:\Users\User\.virtualenvs\myproject-wc-xNQPL\lib\site-packages\django\utils\functional.py", line 80, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\User\.virtualenvs\myproject-wc-xNQPL\lib\site-packages\django\urls\resolvers.py", line 564, in urlconf_module
return import_module(self.urlconf_name)
File "C:\Users\User\.virtualenvs\myproject-wc-xNQPL\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\code\myproject\src\linkcube\urls.py", line 20, in <module>
path('', include('common.urls')),
File "C:\Users\User\.virtualenvs\myproject-wc-xNQPL\lib\site-packages\django\urls\conf.py", line 34, in include
urlconf_module = import_module(urlconf_module)
File "C:\Users\User\.virtualenvs\myproject-wc-xNQPL\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\code\myproject\src\common\urls.py", line 5, in <module>
from . import views
File "C:\code\myproject\src\common\views.py", line 9, in <module>
from django.contrib.auth.mixins import LoginRequiredMixin
File "C:\Users\User\.virtualenvs\myproject-wc-xNQPL\lib\site-packages\django\contrib\auth\mixins.py", line 3, in <module>
from django.contrib.auth.views import redirect_to_login
File "C:\Users\User\.virtualenvs\myproject-wc-xNQPL\lib\site-packages\django\contrib\auth\views.py", line 10, in <module>
from django.contrib.auth.forms import (
File "C:\Users\User\.virtualenvs\myproject-wc-xNQPL\lib\site-packages\django\contrib\auth\forms.py", line 20, in <module>
UserModel = get_user_model()
File "C:\Users\User\.virtualenvs\myproject-wc-xNQPL\lib\site-packages\django\contrib\auth\__init__.py", line 170, in get_user_model
"AUTH_USER_MODEL refers to model '%s' that has not been installed" % settings.AUTH_USER_MODEL
django.core.exceptions.ImproperlyConfigured: AUTH_USER_MODEL refers to model 'auth.User' that has not been installed
C:\code\myproject\src>
最佳答案
所以这里的问题是一个 python 语法错误,但是(也许)因为你正在运行 Django 框架,Django 会抑制它并抛出丢失的模型错误。
由于 python 是解释性语言,它抛出了 SyntaxError
的错误。并且由于存在语法错误,Django 没有找到 auth 模型引用。
这就是为什么你会在那里看到两个错误,python 的 SyntaxError
和 Django 的 ImproperlyConfigured
错误。
Django 好心的让你知道 Django 的错误是由 python 的语法错误引起的。
关于Python Django - "AUTH_USER_MODEL refers to model ' %s' 尚未安装”% settings.AUTH_USER_MODEL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56109815/
我想在 java 中声明一个对象,就像在 C++ 中指向指针的指针,让我给你看一个例子: //*** At the application startup //Initialize a setting
考虑这段代码, struct A {}; struct B { B(const A&) {} }; void f(B) { cout << "f()"<
我正在尝试将一个C程序翻译成Rust。。C程序具有以下结构(归结为MRE):。在一个函数中,我将执行以下指针魔术:。不,我的问题是:我将如何在铁锈中实现同样的目标?。到目前为止,我在《铁锈》中尝试过的
我目前正在尝试将一个C程序翻译成Rust。。C程序具有以下结构(归结为MRE):。在一个函数中,我将执行以下指针魔术:。不,我的问题是:我将如何在铁锈中实现同样的目标?。到目前为止,我在《铁锈》中尝试
这个问题在这里已经有了答案: Add managed DLL dependencied to unmanaged C++ project (1 个回答) 关闭 6 年前。 我有这样一个场景: 使用
这是一个常见问答的集合,这也是一个社区维基,所以每个人都被邀请参与维护它。。正则表达式正在遭受给我ZE代码类型的问题和没有解释的糟糕答案。此参考旨在提供指向质量问答的链接。。此参考适用于以下语言:PH
我正在尝试在方案中模拟堆栈。我正在使用 DrScheme 并选择语言 R5RS。我需要创建 pop、push 和 peek 的函数。但我无法弄清楚如何通过引用传递。我已经阅读了一些关于盒子的信息,但是
我陷入了这个错误。我将代码部署在生产服务器上,它在端口 80 上运行。当我尝试登录管理页面时。如图所示,它给了我 403 错误。 可能是什么原因?我的 Django 代码或 nginx 配置有问题吗?
这是一段简单的 C++ 代码: A foo(){ A a; // create a local A object return a; } void bar(const A & a_r){ }
我正在使用从 torrenteditor 获取的 php 脚本来创建 torrent 文件,但是当我使用指定的方法创建新的 torrent 文件时,torrent 文件被创建但我收到很多通知。,就像这
MySQL: REFERENCES vs FOREIGN KEY + REFERENCES 我认为 REFERENCES 是更冗长的 FOREIGN KEY REFERENCES 语法的某种速记语法。
我想使用基于另一个方法引用的方法引用。这有点难以解释,所以我给你举个例子: Person.java public class Person{ Person sibling; int a
Java/C# 语言律师喜欢说他们的语言通过值传递引用。这意味着“引用”是在调用函数时复制的对象指针。 同时,在 C++ 中(以及在 Perl 和 PHP 中更动态的形式),引用是某个其他名称(或动态
当我需要实现递归 lambda 时,通常我这样做: auto factorial = [](auto& self, int n) -> int { return n == 0 ? 1 : n
我目前正在研究 DDD ,需要一些启发。 我有两个实体 Temple TempleVariant Temple(听筒)包含基本信息(名称,描述等),并具有n个变体,它们具有技术描述(CAD绘图,尺寸,
在 Grails 中 belongsTo允许一个域类与另一个域类建立级联关系。使用belongsTo时有两种类型的关系:引用和无引用。 Reference 在拥有的对象上创建属性,而 No Refer
我正在使用 AWS 和 Django Rest Framework 开发 Web 应用程序。(Django:v1.8,DRF:v3) 我一直在为 POST 多部分表单请求获取 django.reque
我按照下面的定义公开了 WCF 端点, 当我在 .NET 3.5 中添加“服务引用”时,我们在代理中获得了以下类,这非常好: [Syst
我在玩 constexpr 引用时产生了这种感觉。但问题本身与 constexpr 无关,只是被它揭示。 我们知道有“指向const的指针”,也有“const指针”。顺便说一句,由于后者的使用比前者少
我有 2 种类型的 refences,它们中的每一种都可以正常工作。 我尝试使用每一个并在 project build 中得到相同的结果。 请向我解释 COM 引用和引用之间的区别。 谢谢你。 最佳答
我是一名优秀的程序员,十分优秀!