My site appears to deploy correctly on heroku, I can access the main page fine but when I try to login or signup (which directs to a new page) I get the following error:
Traceback (most recent call last):
File "/app/.heroku/python/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "/app/.heroku/python/lib/python3.9/site-packages/django/core/handlers/base.py", line 181, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/app/.heroku/python/lib/python3.9/site-packages/django/views/generic/base.py", line 69, in view
return self.dispatch(request, *args, **kwargs)
File "/app/.heroku/python/lib/python3.9/site-packages/django/utils/decorators.py", line 43, in _wrapper
return bound_method(*args, **kwargs)
File "/app/.heroku/python/lib/python3.9/site-packages/django/views/decorators/debug.py", line 90, in sensitive_post_parameters_wrapper
return view(request, *args, **kwargs)
File "/app/.heroku/python/lib/python3.9/site-packages/allauth/account/views.py", line 146, in dispatch
return super(LoginView, self).dispatch(request, *args, **kwargs)
File "/app/.heroku/python/lib/python3.9/site-packages/allauth/account/views.py", line 74, in dispatch
response = super(RedirectAuthenticatedUserMixin, self).dispatch(
File "/app/.heroku/python/lib/python3.9/site-packages/django/views/generic/base.py", line 101, in dispatch
return handler(request, *args, **kwargs)
File "/app/.heroku/python/lib/python3.9/site-packages/allauth/account/views.py", line 90, in get
response = super(AjaxCapableProcessFormViewMixin, self).get(
File "/app/.heroku/python/lib/python3.9/site-packages/django/views/generic/edit.py", line 135, in get
return self.render_to_response(self.get_context_data())
File "/app/.heroku/python/lib/python3.9/site-packages/allauth/account/views.py", line 177, in get_context_data
site = get_current_site(self.request)
File "/app/.heroku/python/lib/python3.9/site-packages/django/contrib/sites/shortcuts.py", line 13, in get_current_site
return Site.objects.get_current(request)
File "/app/.heroku/python/lib/python3.9/site-packages/django/contrib/sites/models.py", line 58, in get_current
return self._get_site_by_id(site_id)
File "/app/.heroku/python/lib/python3.9/site-packages/django/contrib/sites/models.py", line 30, in _get_site_by_id
site = self.get(pk=site_id)
File "/app/.heroku/python/lib/python3.9/site-packages/django/db/models/manager.py", line 85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/app/.heroku/python/lib/python3.9/site-packages/django/db/models/query.py", line 439, in get
raise self.model.DoesNotExist(
Exception Type: DoesNotExist at /accounts/login/
Exception Value: Site matching query does not exist.
I am using all-auth
for authentication purposes - but I am not sure why this error is being thrown.
Here is my settings.py
rom pathlib import Path
import os
from django.contrib.auth import login
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve(strict=True).parent.parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
[...]
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = ["*"]
LOGIN_URL = '/'
LOGIN_REDIRECT_URL = '/'
LOGOUT_REDIRECT_URL = '/'
# Application definition
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',
# `allauth` needs this from django
'django.template.context_processors.request',
],
},
},
]
# added this for all-auth
[...]
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.gis',
#'shops',
'testingland',
'rest_framework',
'bootstrap_modal_forms',
# all auth
# The following apps are required:
# 'django.contrib.auth',
# 'django.contrib.messages',
'django.contrib.sites',
'allauth',
'allauth.account',
'allauth.socialaccount',
'widget_tweaks',
]
#django-allauth registraion settings
[...]
# 1 day
ACCOUNT_LOGIN_ATTEMPTS_TIMEOUT = 86400
SITE_ID = 1
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 = 'anybody1.urls'
WSGI_APPLICATION = 'anybody1.wsgi.application'
# Database
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.contrib.gis.db.backends.postgis',
# 'ENGINE': 'django.contrib.gis.db.backends.postgis',
'NAME': 'vygr',
'USER': 'x',
'PASSWORD': 'x',
'HOST': 'localhost',
'PORT': '5432'
}
}
[...]
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.1/howto/static-files/
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.9/howto/static-files/
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_URL = '/static/'
# Extra places for collectstatic to find static files.
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
)
[...]
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
import django_heroku
django_heroku.settings(locals())