AttributeError:'RegexURLResolver'对象没有属性'_urlconf_module'

Pra*_*kar 10 python django heroku sentry tastypie

我一直在我的哨兵例外中得到以下错误

AttributeError: 'RegexURLResolver' object has no attribute '_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 (None:None) ^/>
Run Code Online (Sandbox Code Playgroud)

Equ*_*Dev 2

否则我在互联网上发现了这个:

该问题是由导入顺序问题引起的,在您的示例代码中,您调用 urlresolvers.reverse 它将加载 example/urls.py,这将触发 admin.autodiscover() 调用,这将加载social/apps/django_app/default/ admin.py,它将尝试加载您的自定义用户模型,但这将无法加载您的用户模型。

当我直接从 调用函数时,我遇到了问题views.py,并且该函数导致使用了resolve,这可能会导致导入问题,因为直接从 调用函数views.py是不好的风格。然而,上面的评论有助于调试这个问题。

  • 您可能在这里找到它:https://github.com/omab/python-social-auth/issues/269 (2认同)