AttributeError:'RegexURLResolver'对象没有属性'_urlconf_module' [英] AttributeError: 'RegexURLResolver' object has no attribute '_urlconf_module'
问题描述
AttributeError:'RegexURLResolver'对象没有属性'_urlconf_module'
跟踪仅指向使用django代码库的代码,而不指向我的应用程序中的任何位置。我的日志也很干净。这可能是一个可能的原因?
raise Resolver404({'path':path})
@property
def urlconf_module(self):
try:
return self._urlconf_module
except AttributeError:
self._urlconf_module = import_module(self.urlconf_name)
return self._urlconf_module
@property
'self'
< RegexURLResolver urls(无:无)^ />
否则在互联网上我发现这个:
该问题是由导入排序问题引起的,在您调用urlresolvers.reverse的示例代码中会加载example / urls.py,这将会触发一个admin.autodiscover()调用,将加载social / apps / django_app / default / admin.py,这将尝试加载您的自定义用户模型,无法加载您的用户模型。
当我直接从 views.py
调用函数时,我遇到了问题,这个函数导致使用 resolve
,这可能导致导入问题,因为直接从 views.py
调用函数是不好的样式。但是,上述评论有助于med调试问题。
I keep getting the below errors in my sentry exceptions
AttributeError: 'RegexURLResolver' object has no attribute '_urlconf_module'
And the trace only points to code withing the django code base without pointing to any place in my application. My logs are clean too. What could be a possible reason for this?
raise Resolver404({'path' : path})
@property
def urlconf_module(self):
try:
return self._urlconf_module
except AttributeError:
self._urlconf_module = import_module(self.urlconf_name)
return self._urlconf_module
@property
'self'
<RegexURLResolver urls (None:None) ^/>
Otherwise on the Internet I found this:
The issue is caused by an import ordering problem, in your example code you call urlresolvers.reverse which will load example/urls.py, which will trigger an admin.autodiscover() call, which will load social/apps/django_app/default/admin.py, which will try to load your custom user model which will fail to load your user model.
I hit the problem when I called a function directly from views.py
, and this function resulted in use of resolve
, which probably lead to an import problem since calling a function directly from views.py
is bad style. However, the comment above helped med debug the issue.
这篇关于AttributeError:'RegexURLResolver'对象没有属性'_urlconf_module'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!