0

I noticed that some of my urlpatterns have attributes different from the others. Notably _urlconf_module and _urlconf_name are missing. I have been getting a ton of AttributeError: 'RegexURLResolver' object has no attribute '_urlconf_module' errors in production and this seems to be the only clue I got.

Does anyone know why the attributes of the urlconf are different and if that is an issue how could one fix it?

One set of urls of the form url(r'^accounts/register/$', RegistrationView.as_view(), name='registration_register'), has these attributes

{'_callback': <function app1.views.RegistrationView>,
 '_regex': '^accounts/register/$',
 '_regex_dict': {'en-us': re.compile(r'^accounts/register/$', re.UNICODE)},
 'default_args': {},
 'name': 'registration_register'} 

and the other of the form (r'^activation/', include('activation.urls')) has these

{'_app_dict': {},
 '_namespace_dict': {},
 '_regex': '^activation/',
 '_regex_dict': {'en-us': re.compile(r'^activation/', re.UNICODE)},
 '_reverse_dict': {},
 '_urlconf_module': <module 'activation.urls' from '<path to app2>/activation/urls.pyc'>,
 'app_name': None,
 'callback': None,
 'default_kwargs': {},
 'namespace': None,
 'urlconf_name': <module 'activation.urls' from '<path to app2>/activation/urls.pyc'>}

Note that I had upgraded to django-registration-1.0 when the errors started happening which requires me to use class based view and might be one of the underlying reasons.

Pratik Mandrekar
  • 9,362
  • 4
  • 45
  • 65

1 Answers1

0

The second URL pattern has _urlconf_module and _urlconf_name attributes because you are including another URL conf. The first URL pattern is not including a URL conf, so doesn't have these attributes.

Why do you think these internals are causing the problem? It's more likely to be a problem with your own code. It's difficult to help you unless you include a full traceback.

If the traceback does not contain any useful information, it often means that there was an error in one of your modules, which prevents your URL conf from loading. Try importing individual modules in the shell to track down the problems, or remove entries from your URL config until you have a minimal example that reproduces your problem. If other people can reproduce your problem, it's much more likely that they'll be able to help you fix it.

Alasdair
  • 298,606
  • 55
  • 578
  • 516
  • Thanks for the clarification. The point is the only trace I have is this - http://stackoverflow.com/questions/17255561/attributeerror-regexurlresolver-object-has-no-attribute-urlconf-module. I can't reproduce the error locally and it happens only on production. The trace does not point out to any part of my application and I have a hunch it might be happening on application restarts only. – Pratik Mandrekar Jun 23 '13 at 10:55
  • What's the difference between your local and production environments? Are you running sentry locally? – Alasdair Jun 23 '13 at 11:05
  • No I'm not running sentry locally. Will run sentry and check – Pratik Mandrekar Jun 23 '13 at 18:39
  • Running Sentry locally gives me the same error. Looks like there is a correlation between application start and this error. The trace still doesn't help much. Seems like a timing issue of some kind. – Pratik Mandrekar Jun 25 '13 at 21:58