{% providers_media_js %} causes: Error during template rendering, Site matching query does not exist

Viewed 13

I'm trying to add facebook auth through django-allauth and everything is working fine when I run on localhost (except that I can't actually login because I have no SSL cert on localhost)

when I push to Heroku, everything is fine except for my login page, where I get this error

Error during template rendering

In template /app/templates/main.html, error at line 2
Site matching query does not exist.

my main.html:

{% load socialaccount %}
{% providers_media_js %}  // error here
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h1>Hello</h1>
    <a href="{% provider_login_url 'facebook' method='js_sdk' %}">Login with Facebook</a>
</body>
</html>

my settings.py info:

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'base.apps.BaseConfig',
    'rest_framework',
    'rest_framework.authtoken',
    'corsheaders',
    'dj_rest_auth',
    'django.contrib.sites',
    'allauth',
    'allauth.account',
    'allauth.socialaccount',
    'dj_rest_auth.registration',
    'allauth.socialaccount.providers.facebook',
    'django_extensions',
]

SITE_ID = 1

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    "whitenoise.middleware.WhiteNoiseMiddleware",
    "corsheaders.middleware.CorsMiddleware",
    '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',
    
]

AUTHENTICATION_BACKENDS = (
    'allauth.account.auth_backends.AuthenticationBackend',
    'django.contrib.auth.backends.ModelBackend',
)


SOCIALACCOUNT_PROVIDERS = \
    {'facebook':
       {'METHOD': 'oauth2',
        'SCOPE': ['email','public_profile', 'user_friends'],
        'AUTH_PARAMS': {'auth_type': 'reauthenticate'},
        'FIELDS': [
            'id',
            'email',
            'name',
            'first_name',
            'last_name',
            'verified',
            'locale',
            'timezone',
            'link',
            'gender',
            'updated_time'],
        'EXCHANGE_TOKEN': True,
        'LOCALE_FUNC': lambda request: 'kr_KR',
        'VERIFIED_EMAIL': False,
        'VERSION': 'v2.4'}}
#facebook
SOCIAL_AUTH_FACEBOOK_KEY = ''  # App ID here
SOCIAL_AUTH_FACEBOOK_SECRET ='' #app key here

ALLOWED_HOSTS = ["myappnamehere.heroku.com"] 
#also tried ALLOWED_HOSTS = ["*"]

notes:

  • I do have my domain in sites sections in the django admin page "myappnamehere.heroku.com/admin"
  • I do have facebook-sdk and all other necissary libraries on Heroku
0 Answers
Related