0

I'm using allauth in my Django app for basic sign-in, sign-up, password reset functionality, etc. I've attached Gmail as the social account and migrated my data tables.

I have two sites set up in the the admin page: one with my domain name http://owexpenses.herokuapp.com/ and one with localhost:8000/

Everything is working fine in localhost. However, when deployed to Heroku, with the Heroku site id set in settings.py, users that sign up keep getting magically deleted and are replaced with the users I've signed up in the localhost site.

I've tried adding users in Heroku, which works. Then a couple hours later, I'll check, and those users will have disappeared. There is no error message, but I thought I'd post this problem in the off-chance that someone has encountered it. I just can't imagine allauth would have such a huge bug. I must be missing something.

Here are my settings, in case that is where the problem lies:

""" Django settings for expensesApp project.

Generated by 'django-admin startproject' using Django 1.10.3.

For more information on this file, see
https://docs.djangoproject.com/en/1.10/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.10/ref/settings/
"""

import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'vl!7@x=%_l&!ys=m!-@+m3uu@t8-n)(gzgb-9^^osh5ryt@t!5'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

#add 'localhost'
ALLOWED_HOSTS = ['owexpenses.herokuapp.com', 'localhost']


# Application definition

INSTALLED_APPS = [
    'django.contrib.sites',
    'registration'
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'constraints.apps.ConstraintsConfig',
]

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 = 'expensesApp.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'templates')],
        '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',
            ],
        },
    },
]

WSGI_APPLICATION = 'expensesApp.wsgi.application'

# Database
# https://docs.djangoproject.com/en/1.10/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}


# Password validation
# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]

# Internationalization
# https://docs.djangoproject.com/en/1.10/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.10/howto/static-files/
PROJECT_DIR = os.path.dirname(os.path.abspath(__file__))
STATICFILES_DIRS = (os.path.join(PROJECT_DIR,'static'),)
STATIC_ROOT = '/expensesApp/static/'
STATIC_URL = '/static/'

#Authorization related
LOGIN_REDIRECT_URL = '/'
AUTH_PROFILE_MODULE = 'UserProfile'
AUTHENTICATION_BACKENDS = ['django.contrib.auth.backends.ModelBackend']
# Ensure the SITE_ID is defined 
#SITE_ID = '3'

# Ensure EMAIL_BACKEND is set so allauth can proceed to send confirmation emails
# Set to console for development/testing

# EMAIL_BACKEND='django.core.mail.backends.console.EmailBackend'
EMAIL_HOST = 'smtp.sendgrid.net'
EMAIL_HOST_USER = 'my_username'
EMAIL_HOST_PASSWORD = '############'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL  = 'my_email@gmail.com'

Custom allauth settings
Use email as the primary identifier
ACCOUNT_AUTHENTICATION_METHOD = 'email' 
ACCOUNT_EMAIL_REQUIRED = True
# Make email verification mandatory to avoid junk email accounts
ACCOUNT_EMAIL_VERIFICATION = 'mandatory' 
# Eliminate need to provide username, as it's a very old practice
ACCOUNT_USERNAME_REQUIRED = True
ACCOUNT_LOGOUT_ON_GET = True
Lina Huang
  • 19
  • 2
  • Try to separate your settings files. https://medium.com/@ayarshabeer/django-best-practice-settings-file-for-multiple-environments-6d71c6966ee2#.y3jqza128 – Mehdi Pourfar Jan 13 '17 at 22:57
  • Thanks! I think it's actually because I'm using sqlite3 and not Postgresql – Lina Huang Jan 14 '17 at 23:06

0 Answers0