AttributeError: 'RegexURLResolver' object has no attribute '_urlconf_module'

北慕城南 提交于 2019-12-01 14:29:08

问题


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) ^/>

回答1:


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.



来源:https://stackoverflow.com/questions/17255561/attributeerror-regexurlresolver-object-has-no-attribute-urlconf-module

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!