Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'RegexURLResolver' object has no attribute '_urlconf_module' #269

Closed
ariovistus opened this issue May 8, 2014 · 1 comment
Closed

'RegexURLResolver' object has no attribute '_urlconf_module' #269

ariovistus opened this issue May 8, 2014 · 1 comment

Comments

@ariovistus
Copy link

When I change the models.py in the django example to this:

from django.db import models
from django.contrib import auth
from django.core import urlresolvers

class CustomUser(auth.models.AbstractBaseUser, auth.models.PermissionsMixin):
    email = models.EmailField(unique=True, error_messages={'unique':
         urlresolvers.reverse("example.app.views.logout")  })

the following exception gets thrown:

Traceback (most recent call last):
     File "/home/ario/.virtualenvs/mdp/lib/python3.3/site-packages/django   /core/urlresolvers.py", line 358, in urlconf_module
     return self._urlconf_module
AttributeError: 'RegexURLResolver' object has no attribute '_urlconf_module'

In a vanilla django app with above models.py, this does not happen.

@omab omab closed this as completed in feba420 May 17, 2014
@omab
Copy link
Owner

omab commented May 17, 2014

@ariovistus, 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've included a setting to avoid this issue (not released yet), you can define SOCIAL_AUTH_ADMIN_USER_SEARCH_FIELDS = ['first_name', 'last_name', 'email', 'username'] (the setting value is a list of fields of your custom user), this will avoid the import order problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants