''social' is not a registered namespace
Im trying to implement google authentication but I got the following error:
django.urls.exceptions.NoReverseMatch: 'social' is not a registered namespace
i have like this in my login.html:
<a href="{% url 'social:begin' 'google-oauth2' %}"> Sign in with Google</a>
I also added this in my setting.py
SOCIAL_AUTH_URL_NAMESPACE = 'social'
url.py
urlpatterns = [
path('admin/', admin.site.urls),
path('register/', user_views.register, name='register'),
path('profile/', user_views.profile, name='profile'),
path('login/', auth_views.LoginView.as_view(template_name='users/login.html'), name='login'),
path('login/', include('allauth.urls')),
path('logout/', auth_views.LogoutView.as_view(template_name='users/logout.html'), name='logout'),
path('', include('blog.urls')),
]
Does anyone know how to solve this?
Solution 1:[1]
Add the following in urls.py where the url with namespace 'begin' has been defined, before url pattern
app_name = 'social'
Solution 2:[2]
Try this:
<a href="{% url 'begin' 'google-oauth2' %}"> Sign in with Google</a>
Updated
Please fix the URL mapping conflict as mentioned by @John Gordon:
path('login/', auth_views.LoginView.as_view(template_name='users/login.html'), name='login'),
path('login/', include('allauth.urls')),
You can't have two identical url patterns since Django finds the first one and then doesn't go further down the list if the first is a match. You can name it anything else such as 'accounts', 'users', you get the idea like so:
path('accounts/', include('allauth.urls')),
Do this change then see what you get and report back. Also, please include the settings.py file with your question as a code section rather than a comment.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Tejas nayak |
| Solution 2 |
