When using django-cassandra-engine sessions I get an error in INSTALLED_APPS

2

I'm using django-cassandra-engine for session storage, when I start the server I get this error:

RuntimeError: Model class django.contrib.sessions.models.Session doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS

The steps I followed are these link

INSTALLED_APPS += ['django_cassandra_engine.sessions']

SESSION_BACKEND = 'django_cassandra_engine.sessions.backends.db'

My settings file:

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__)))
WORK_DIR = os.getcwd()


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

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '*******'

# Application definition

INSTALLED_APPS = [
    'django_cassandra_engine',
    'django_cassandra_engine.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    ....
]

SESSION_BACKEND = 'django_cassandra_engine.sessions.backends.db'

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = '.....urls'


TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(WORK_DIR, "templates"),],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

WSGI_APPLICATION = '.....wsgi.application'


LANGUAGE_CODE = 'es-EC'
TIME_ZONE = 'America/Guayaquil'
USE_I18N = True
USE_L10N = True
USE_TZ = True


MEDIA_ROOT = os.path.join(WORK_DIR, 'media')
MEDIA_URL = '/media/'
STATICFILES_DIRS = [
    os.path.join(WORK_DIR, "static"),
]
STATIC_URL = '/static/'
    
asked by EdgarAlejandro 02.08.2017 в 00:35
source

1 answer

2

I think the error is the name of the Django setting to specify the backend to be used.

Instead of using SESSION_BACKEND try to change to SESSION_ENGINE :

SESSION_ENGINE = 'django_cassandra_engine.sessions.backends.db'

The django-cassandra-engine documentation must be outdated. That's why you get that error because, by default, the value of SESSION_ENGINE is:

SESSION_ENGINE = 'django.contrib.sessions.backends.db'

But as you said, I could not find it. With this change it should work.

    
answered by 02.08.2017 / 01:42
source