I hit the bug first here:
Reverse for 'google_login' not found. 'google_login' is not a valid view function or pattern name.
on my home page
After some digging I realized that I do not have any url that is of the pattern ‘accounts/google/…’
I used to have all these urls previously in this same project, They seem to have dissapeared. [Returned to this project after a while]
Do let mw know if you have any insights you could have on how I could solve it.
[part of] My settings.py:
...
ALLOWED_HOSTS = []
SITE_ID = 1 # for app django.contrib.sites
AUTHENTICATION_BACKENDS = [
# Needed to login by username in Django admin, regardless of `allauth`
'django.contrib.auth.backends.ModelBackend',
# `allauth` specific authentication methods, such as login by e-mail
'allauth.account.auth_backends.AuthenticationBackend',
]
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
# added 3rd party apps:
'django.contrib.sites', # required by allauth
'allauth',
'allauth.account', # local account
'allauth.socialaccount', # social account login
'allauth.socialaccount.providers.google',
# adding created apps:
'websiteMain.apps.WebsitemainConfig',
]
LOGIN_REDIRECT_URL = "/"
# Provider specific settings
SOCIALACCOUNT_PROVIDERS = {
'google': {
'APP': {
'client_id': '<MyID>',
'secret': '<MySecret>',
# 'key': ''
},
'SCOPE': [
'profile',
'email',
],
'AUTH_PARAMS': {
'access_type': 'online', # default
},
'OAUTH_PKCE_ENABLED': True,
}
}
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'asapawa.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
# ADDED:
# `allauth` needs this from django
'django.template.context_processors.request',
],
},
},
]
WSGI_APPLICATION = 'asapawa.wsgi.application'
# Database
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
...
my project’s urls.py:
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
#ALL AUTH:
path('accounts/', include('allauth.urls')),
#MAIN APP: [make sure to keep it last]
path('', include("websiteMain.urls"))
]
Using Django==3.2.19 and django-allauth==0.54.0