nephila / djangocms-multisite

django-multisite support for DjangoCMS
BSD 3-Clause "New" or "Revised" License
26 stars 19 forks source link

ERROR: ValueError: SITE_ID has not been set. #2

Closed bartmika closed 8 years ago

bartmika commented 8 years ago

I am trying to figure out the setup of this library. I read this in the README.rst:

Configure django-multisite as documented

So I read the instructions here: https://github.com/ecometrica/django-multisite and then I try to test it out. but I get the following error:

  Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x111686378>
Traceback (most recent call last):
  File "/Users/bartlomiejmika/Developer/rodolfomartinez/cloudmasterstudios/djangocms-cloudmasterstudios/env/lib/python3.4/site-packages/django/utils/autoreload.py", line 229, in wrapper
    fn(*args, **kwargs)
  File "/Users/bartlomiejmika/Developer/rodolfomartinez/cloudmasterstudios/djangocms-cloudmasterstudios/env/lib/python3.4/site-packages/django/core/management/commands/runserver.py", line 107, in inner_run
    autoreload.raise_last_exception()
  File "/Users/bartlomiejmika/Developer/rodolfomartinez/cloudmasterstudios/djangocms-cloudmasterstudios/env/lib/python3.4/site-packages/django/utils/autoreload.py", line 252, in raise_last_exception
    six.reraise(*_exception)
  File "/Users/bartlomiejmika/Developer/rodolfomartinez/cloudmasterstudios/djangocms-cloudmasterstudios/env/lib/python3.4/site-packages/django/utils/six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "/Users/bartlomiejmika/Developer/rodolfomartinez/cloudmasterstudios/djangocms-cloudmasterstudios/env/lib/python3.4/site-packages/django/utils/autoreload.py", line 229, in wrapper
    fn(*args, **kwargs)
  File "/Users/bartlomiejmika/Developer/rodolfomartinez/cloudmasterstudios/djangocms-cloudmasterstudios/env/lib/python3.4/site-packages/django/__init__.py", line 18, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/Users/bartlomiejmika/Developer/rodolfomartinez/cloudmasterstudios/djangocms-cloudmasterstudios/env/lib/python3.4/site-packages/django/apps/registry.py", line 108, in populate
    app_config.import_models(all_models)
  File "/Users/bartlomiejmika/Developer/rodolfomartinez/cloudmasterstudios/djangocms-cloudmasterstudios/env/lib/python3.4/site-packages/django/apps/config.py", line 198, in import_models
    self.models_module = import_module(models_module_name)
  File "/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/importlib/__init__.py", line 109, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
  File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
  File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1129, in _exec
  File "<frozen importlib._bootstrap>", line 1471, in exec_module
  File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
  File "/Users/bartlomiejmika/Developer/rodolfomartinez/cloudmasterstudios/djangocms-cloudmasterstudios/env/lib/python3.4/site-packages/djangocms_inherit/models.py", line 11, in <module>
    class InheritPagePlaceholder(CMSPlugin):
  File "/Users/bartlomiejmika/Developer/rodolfomartinez/cloudmasterstudios/djangocms-cloudmasterstudios/env/lib/python3.4/site-packages/djangocms_inherit/models.py", line 22, in InheritPagePlaceholder
    _("language"), max_length=5, choices=get_language_tuple(), blank=True,
  File "/Users/bartlomiejmika/Developer/rodolfomartinez/cloudmasterstudios/djangocms-cloudmasterstudios/env/lib/python3.4/site-packages/cms/utils/i18n.py", line 76, in get_language_tuple
    return [(lang['code'], lang['name']) for lang in get_languages(site_id)]
  File "/Users/bartlomiejmika/Developer/rodolfomartinez/cloudmasterstudios/djangocms-cloudmasterstudios/env/lib/python3.4/site-packages/cms/utils/i18n.py", line 24, in get_languages
    result = get_cms_setting('LANGUAGES').get(site_id)
  File "/Users/bartlomiejmika/Developer/rodolfomartinez/cloudmasterstudios/djangocms-cloudmasterstudios/env/lib/python3.4/site-packages/cms/utils/conf.py", line 270, in get_cms_setting
    return COMPLEX[name]()
  File "/Users/bartlomiejmika/Developer/rodolfomartinez/cloudmasterstudios/djangocms-cloudmasterstudios/env/lib/python3.4/site-packages/cms/utils/conf.py", line 224, in get_languages
    if settings.SITE_ID != hash(settings.SITE_ID):
  File "/Users/bartlomiejmika/Developer/rodolfomartinez/cloudmasterstudios/djangocms-cloudmasterstudios/env/lib/python3.4/site-packages/multisite/threadlocals.py", line 93, in __hash__
    return self.__int__()
  File "/Users/bartlomiejmika/Developer/rodolfomartinez/cloudmasterstudios/djangocms-cloudmasterstudios/env/lib/python3.4/site-packages/multisite/threadlocals.py", line 59, in __int__
    return self.get_default()
  File "/Users/bartlomiejmika/Developer/rodolfomartinez/cloudmasterstudios/djangocms-cloudmasterstudios/env/lib/python3.4/site-packages/multisite/threadlocals.py", line 123, in get_default
    raise ValueError('SITE_ID has not been set.')

I am scratching my head as to why Django-CMS does this. Do you know what's going on? Here is my settings.py file:

import os
import dj_database_url
gettext = lambda s: s
DATA_DIR = os.path.dirname(os.path.dirname(__file__))
"""
Django settings for cloudmasterstudios project.

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

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

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

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

from os.path import join, dirname
from dotenv import load_dotenv

dotenv_path = join(dirname(__file__), '.env')
load_dotenv(dotenv_path)

def env_var(key, default=None):
    """Retrieves env vars and makes Python boolean replacements"""
    val = os.environ.get(key, default)
    if val == 'True':
        val = True
    elif val == 'False':
        val = False
    return val

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

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = env_var("SECRET_KEY")

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = env_var("IS_DEBUG")

ALLOWED_HOSTS = [env_var("ALLOWED_HOSTS")]

# The person to contact on error when DEBUG=False
ADMINS = [(env_var("ADMIN_NAME"), env_var("ADMIN_EMAIL")),]

# Honor the 'X-Forwarded-Proto' header for request.is_secure()
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')

# Application definition

from multisite import SiteID
SITE_ID = SiteID()  # <=------- THIS IS WHERE THE ERROR OCCURS

ROOT_URLCONF = 'cloudmasterstudios.urls'

WSGI_APPLICATION = 'cloudmasterstudios.wsgi.application'

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

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

LANGUAGE_CODE = 'en'

TIME_ZONE = 'America/Toronto'

USE_I18N = True

USE_L10N = True

USE_TZ = True

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.8/howto/static-files/

STATIC_URL = '/static/'
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(DATA_DIR, 'media')
STATIC_ROOT = os.path.join(DATA_DIR, 'static')

STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'cloudmasterstudios', 'static'),
)

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'cloudmasterstudios', 'templates'),],
        'OPTIONS': {
            'context_processors': [
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
                'django.core.context_processors.i18n',
                'django.core.context_processors.debug',
                'django.core.context_processors.request',
                'django.core.context_processors.media',
                'django.core.context_processors.csrf',
                'django.core.context_processors.tz',
                'sekizai.context_processors.sekizai',
                'django.core.context_processors.static',
                'cms.context_processors.cms_settings',
                'multisite.middleware.DynamicSiteMiddleware',
                'aldryn_boilerplates.context_processors.boilerplate',
            ],
            'loaders': [
                'django.template.loaders.filesystem.Loader',
                'multisite.template_loader.Loader',
                'django.template.loaders.app_directories.Loader',
                'django.template.loaders.eggs.Loader',
                'aldryn_boilerplates.template_loaders.AppDirectoriesLoader',
            ],
        },
    },
]

MIDDLEWARE_CLASSES = [
    'htmlmin.middleware.HtmlMinifyMiddleware',
    'cms.middleware.utils.ApphookReloadMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.locale.LocaleMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'cms.middleware.user.CurrentUserMiddleware',
    'cms.middleware.page.CurrentPageMiddleware',
    'cms.middleware.toolbar.ToolbarMiddleware',
    'cms.middleware.language.LanguageCookieMiddleware',
    'htmlmin.middleware.MarkRequestMiddleware',
]

INSTALLED_APPS = [
    # Django & Django-CMS
    'djangocms_admin_style',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.admin',
    'django.contrib.sites',
    'django.contrib.sitemaps',
    'django.contrib.staticfiles',
    'django.contrib.messages',
    'cms',
    'menus',
    'sekizai',
    'treebeard',
    'djangocms_text_ckeditor',
    'djangocms_style',
    'djangocms_column',
    'filer',
    'easy_thumbnails',
    'cmsplugin_filer_image',
    'cmsplugin_filer_file',
    'cmsplugin_filer_folder',
    'cmsplugin_filer_teaser',
    'cmsplugin_filer_utils',
    'cmsplugin_filer_video',
    'djangocms_googlemap',
    'djangocms_inherit',
    'djangocms_link',
    'reversion',
    # Django-CMS Blogging
    'aldryn_apphooks_config',
    'aldryn_boilerplates',
    'aldryn_categories',
    'aldryn_newsblog',
    'aldryn_people',
    'aldryn_reversion',
    'aldryn_common',
    'parler',
    'sortedm2m',
    'taggit',
    'aldryn_disqus',
    # Third Party
    'compressor',
    # Custom
    'cloudmasterstudios'
]

LANGUAGES = (
    ## Customize this
    ('en', gettext('en')),
    ('', gettext('')),
)

CMS_LANGUAGES = {
    ## Customize this
    1: [
        {
            'redirect_on_fallback': True,
            'hide_untranslated': False,
            'code': 'en',
            'public': True,
            'name': gettext('en'),
        },
        {
            'redirect_on_fallback': True,
            'hide_untranslated': False,
            'code': '',
            'public': True,
            'name': gettext(''),
        },
    ],
    'default': {
        'redirect_on_fallback': True,
        'hide_untranslated': False,
        'public': True,
    },
}

CMS_TEMPLATES = (
    ## Customize this
    ('fullwidth.html', 'Fullwidth'),
    ('sidebar_left.html', 'Sidebar Left'),
    ('sidebar_right.html', 'Sidebar Right')
)

CMS_PERMISSION = True

CMS_PLACEHOLDER_CONF = {}

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

DATABASES = {
    'default': {
        'CONN_MAX_AGE': 0,
        "ENGINE": "django.db.backends.postgresql_psycopg2"
    }
}
DATABASES['default'] = dj_database_url.config(default=env_var("DATABASE_URL"))

MIGRATION_MODULES = {
    'cmsplugin_filer_folder': 'cmsplugin_filer_folder.migrations_django',
    'cmsplugin_filer_video': 'cmsplugin_filer_video.migrations_django',
    'cmsplugin_filer_file': 'cmsplugin_filer_file.migrations_django',
    'cmsplugin_filer_image': 'cmsplugin_filer_image.migrations_django',
    'cmsplugin_filer_teaser': 'cmsplugin_filer_teaser.migrations_django'
}

THUMBNAIL_PROCESSORS = (
    'easy_thumbnails.processors.colorspace',
    'easy_thumbnails.processors.autocrop',
    'filer.thumbnail_processors.scale_and_crop_with_subject_location',
    'easy_thumbnails.processors.filters'
)

ALDRYN_BOILERPLATE_NAME='bootstrap3'

STATICFILES_FINDERS = [
  'django.contrib.staticfiles.finders.FileSystemFinder',
  'aldryn_boilerplates.staticfile_finders.AppDirectoriesFinder',
  'django.contrib.staticfiles.finders.AppDirectoriesFinder',
]

Any help would be appreciated!

rodolfomartinez commented 8 years ago

+1

yakky commented 8 years ago

@bartmika try SITE_ID = SiteID(default=1)

bartmika commented 8 years ago

That fixed that error! Thanks @yakky. I am now getting a different error and I am wondering if you got it before:

Environment:

Request Method: GET
Request URL: http://example.com/en/

Django Version: 1.8.13
Python Version: 3.4.2
Installed Applications:
['djangocms_admin_style',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.admin',
 'django.contrib.sites',
 'django.contrib.sitemaps',
 'django.contrib.staticfiles',
 'django.contrib.messages',
 'cms',
 'menus',
 'sekizai',
 'treebeard',
 'djangocms_text_ckeditor',
 'djangocms_style',
 'djangocms_column',
 'filer',
 'easy_thumbnails',
 'cmsplugin_filer_image',
 'cmsplugin_filer_file',
 'cmsplugin_filer_folder',
 'cmsplugin_filer_teaser',
 'cmsplugin_filer_utils',
 'cmsplugin_filer_video',
 'djangocms_googlemap',
 'djangocms_inherit',
 'djangocms_link',
 'reversion',
 'aldryn_apphooks_config',
 'aldryn_boilerplates',
 'aldryn_categories',
 'aldryn_newsblog',
 'aldryn_people',
 'aldryn_reversion',
 'aldryn_common',
 'parler',
 'sortedm2m',
 'taggit',
 'aldryn_disqus',
 'compressor',
 'cloudmasterstudios']
Installed Middleware:
['htmlmin.middleware.HtmlMinifyMiddleware',
 'multisite.middleware.DynamicSiteMiddleware',
 'cms.middleware.utils.ApphookReloadMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.locale.LocaleMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'cms.middleware.user.CurrentUserMiddleware',
 'cms.middleware.page.CurrentPageMiddleware',
 'cms.middleware.toolbar.ToolbarMiddleware',
 'cms.middleware.language.LanguageCookieMiddleware',
 'htmlmin.middleware.MarkRequestMiddleware']

Traceback:
File "/Users/bartlomiejmika/Developer/rodolfomartinez/cloudmasterstudios/djangocms-cloudmasterstudios/env/lib/python3.4/site-packages/django/core/handlers/base.py" in get_response
  108.                 response = middleware_method(request)
File "/Users/bartlomiejmika/Developer/rodolfomartinez/cloudmasterstudios/djangocms-cloudmasterstudios/env/lib/python3.4/site-packages/multisite/middleware.py" in process_request
  174.         alias = self.get_alias(netloc)
File "/Users/bartlomiejmika/Developer/rodolfomartinez/cloudmasterstudios/djangocms-cloudmasterstudios/env/lib/python3.4/site-packages/multisite/middleware.py" in get_alias
  108.             alias = Alias.objects.resolve(host=host, port=port)
File "/Users/bartlomiejmika/Developer/rodolfomartinez/cloudmasterstudios/djangocms-cloudmasterstudios/env/lib/python3.4/site-packages/multisite/models.py" in resolve
  52.         aliases = dict((a.domain, a) for a in self.get_queryset().filter(q))
File "/Users/bartlomiejmika/Developer/rodolfomartinez/cloudmasterstudios/djangocms-cloudmasterstudios/env/lib/python3.4/site-packages/django/db/models/query.py" in __iter__
  162.         self._fetch_all()
File "/Users/bartlomiejmika/Developer/rodolfomartinez/cloudmasterstudios/djangocms-cloudmasterstudios/env/lib/python3.4/site-packages/django/db/models/query.py" in _fetch_all
  965.             self._result_cache = list(self.iterator())
File "/Users/bartlomiejmika/Developer/rodolfomartinez/cloudmasterstudios/djangocms-cloudmasterstudios/env/lib/python3.4/site-packages/django/db/models/query.py" in iterator
  238.         results = compiler.execute_sql()
File "/Users/bartlomiejmika/Developer/rodolfomartinez/cloudmasterstudios/djangocms-cloudmasterstudios/env/lib/python3.4/site-packages/django/db/models/sql/compiler.py" in execute_sql
  840.             cursor.execute(sql, params)
File "/Users/bartlomiejmika/Developer/rodolfomartinez/cloudmasterstudios/djangocms-cloudmasterstudios/env/lib/python3.4/site-packages/django/db/backends/utils.py" in execute
  79.             return super(CursorDebugWrapper, self).execute(sql, params)
File "/Users/bartlomiejmika/Developer/rodolfomartinez/cloudmasterstudios/djangocms-cloudmasterstudios/env/lib/python3.4/site-packages/django/db/backends/utils.py" in execute
  64.                 return self.cursor.execute(sql, params)
File "/Users/bartlomiejmika/Developer/rodolfomartinez/cloudmasterstudios/djangocms-cloudmasterstudios/env/lib/python3.4/site-packages/django/db/utils.py" in __exit__
  98.                 six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/Users/bartlomiejmika/Developer/rodolfomartinez/cloudmasterstudios/djangocms-cloudmasterstudios/env/lib/python3.4/site-packages/django/utils/six.py" in reraise
  685.             raise value.with_traceback(tb)
File "/Users/bartlomiejmika/Developer/rodolfomartinez/cloudmasterstudios/djangocms-cloudmasterstudios/env/lib/python3.4/site-packages/django/db/backends/utils.py" in execute
  64.                 return self.cursor.execute(sql, params)

Exception Type: ProgrammingError at /en/
Exception Value: relation "multisite_alias" does not exist
LINE 1: ..."django_site"."domain", "django_site"."name" FROM "multisite...
                                                             ^

My current settings.py file now looks like this:

import os
import dj_database_url
gettext = lambda s: s
DATA_DIR = os.path.dirname(os.path.dirname(__file__))
"""
Django settings for cloudmasterstudios project.

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

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

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

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

from os.path import join, dirname
from dotenv import load_dotenv

dotenv_path = join(dirname(__file__), '.env')
load_dotenv(dotenv_path)

def env_var(key, default=None):
    """Retrieves env vars and makes Python boolean replacements"""
    val = os.environ.get(key, default)
    if val == 'True':
        val = True
    elif val == 'False':
        val = False
    return val

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

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = env_var("SECRET_KEY")

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = env_var("IS_DEBUG")

ALLOWED_HOSTS = [env_var("ALLOWED_HOSTS")]

# The person to contact on error when DEBUG=False
ADMINS = [(env_var("ADMIN_NAME"), env_var("ADMIN_EMAIL")),]

# Honor the 'X-Forwarded-Proto' header for request.is_secure()
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')

# Application definition

from multisite import SiteID
SITE_ID = SiteID(default=1)

ROOT_URLCONF = 'cloudmasterstudios.urls'

WSGI_APPLICATION = 'cloudmasterstudios.wsgi.application'

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

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

LANGUAGE_CODE = 'en'

TIME_ZONE = 'America/Toronto'

USE_I18N = True

USE_L10N = True

USE_TZ = True

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.8/howto/static-files/

STATIC_URL = '/static/'
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(DATA_DIR, 'media')
STATIC_ROOT = os.path.join(DATA_DIR, 'static')

STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'cloudmasterstudios', 'static'),
)

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'cloudmasterstudios', 'templates'),],
        'OPTIONS': {
            'context_processors': [
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
                'django.core.context_processors.i18n',
                'django.core.context_processors.debug',
                'django.core.context_processors.request',
                'django.core.context_processors.media',
                'django.core.context_processors.csrf',
                'django.core.context_processors.tz',
                'sekizai.context_processors.sekizai',
                'django.core.context_processors.static',
                'cms.context_processors.cms_settings',
                'aldryn_boilerplates.context_processors.boilerplate',
            ],
            'loaders': [
                'django.template.loaders.filesystem.Loader',
                'multisite.template_loader.Loader',
                'django.template.loaders.app_directories.Loader',
                'django.template.loaders.eggs.Loader',
                'aldryn_boilerplates.template_loaders.AppDirectoriesLoader',
            ],
        },
    },
]

MIDDLEWARE_CLASSES = [
    'htmlmin.middleware.HtmlMinifyMiddleware',
    'cms.middleware.utils.ApphookReloadMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.locale.LocaleMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'cms.middleware.user.CurrentUserMiddleware',
    'cms.middleware.page.CurrentPageMiddleware',
    'cms.middleware.toolbar.ToolbarMiddleware',
    'cms.middleware.language.LanguageCookieMiddleware',
    'multisite.middleware.DynamicSiteMiddleware',
    'htmlmin.middleware.MarkRequestMiddleware',
]

INSTALLED_APPS = [
    # Django & Django-CMS
    'djangocms_admin_style',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.admin',
    'django.contrib.sites',
    'django.contrib.sitemaps',
    'django.contrib.staticfiles',
    'django.contrib.messages',
    'cms',
    'menus',
    'sekizai',
    'treebeard',
    'djangocms_text_ckeditor',
    'djangocms_style',
    'djangocms_column',
    'filer',
    'easy_thumbnails',
    'cmsplugin_filer_image',
    'cmsplugin_filer_file',
    'cmsplugin_filer_folder',
    'cmsplugin_filer_teaser',
    'cmsplugin_filer_utils',
    'cmsplugin_filer_video',
    'djangocms_googlemap',
    'djangocms_inherit',
    'djangocms_link',
    'reversion',
    # Django-CMS Blogging
    'aldryn_apphooks_config',
    'aldryn_boilerplates',
    'aldryn_categories',
    'aldryn_newsblog',
    'aldryn_people',
    'aldryn_reversion',
    'aldryn_common',
    'parler',
    'sortedm2m',
    'taggit',
    'aldryn_disqus',
    # Third Party
    'compressor',
    # Custom
    'cloudmasterstudios'
]

LANGUAGES = (
    ## Customize this
    ('en', gettext('en')),
    ('', gettext('')),
)

CMS_LANGUAGES = {
    ## Customize this
    1: [
        {
            'redirect_on_fallback': True,
            'hide_untranslated': False,
            'code': 'en',
            'public': True,
            'name': gettext('en'),
        },
        {
            'redirect_on_fallback': True,
            'hide_untranslated': False,
            'code': '',
            'public': True,
            'name': gettext(''),
        },
    ],
    'default': {
        'redirect_on_fallback': True,
        'hide_untranslated': False,
        'public': True,
    },
}

CMS_TEMPLATES = (
    ## Customize this
    ('fullwidth.html', 'Fullwidth'),
    ('sidebar_left.html', 'Sidebar Left'),
    ('sidebar_right.html', 'Sidebar Right')
)

CMS_PERMISSION = True

CMS_PLACEHOLDER_CONF = {}

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

DATABASES = {
    'default': {
        'CONN_MAX_AGE': 0,
        "ENGINE": "django.db.backends.postgresql_psycopg2"
    }
}
DATABASES['default'] = dj_database_url.config(default=env_var("DATABASE_URL"))

MIGRATION_MODULES = {
    'cmsplugin_filer_folder': 'cmsplugin_filer_folder.migrations_django',
    'cmsplugin_filer_video': 'cmsplugin_filer_video.migrations_django',
    'cmsplugin_filer_file': 'cmsplugin_filer_file.migrations_django',
    'cmsplugin_filer_image': 'cmsplugin_filer_image.migrations_django',
    'cmsplugin_filer_teaser': 'cmsplugin_filer_teaser.migrations_django'
}

THUMBNAIL_PROCESSORS = (
    'easy_thumbnails.processors.colorspace',
    'easy_thumbnails.processors.autocrop',
    'filer.thumbnail_processors.scale_and_crop_with_subject_location',
    'easy_thumbnails.processors.filters'
)

ALDRYN_BOILERPLATE_NAME='bootstrap3'

STATICFILES_FINDERS = [
  'django.contrib.staticfiles.finders.FileSystemFinder',
  'aldryn_boilerplates.staticfile_finders.AppDirectoriesFinder',
  'django.contrib.staticfiles.finders.AppDirectoriesFinder',
]

Thanks for the continuous help.

yakky commented 8 years ago

@bartmika I can't see multisite into INSTALLED_APPS. I checked the upstream documentation and infact it does not mention that. I'll edit the readme to mention these two additional settings

bartmika commented 8 years ago

Added and I still get the same error. I tried deleting the env folder and re-installing the libraries and then re-running python manage.py makemigrations and I still get that error. Here's my new settings.py file.

import os
import dj_database_url
gettext = lambda s: s
DATA_DIR = os.path.dirname(os.path.dirname(__file__))
"""
Django settings for cloudmasterstudios project.

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

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

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

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

from os.path import join, dirname
from dotenv import load_dotenv

dotenv_path = join(dirname(__file__), '.env')
load_dotenv(dotenv_path)

def env_var(key, default=None):
    """Retrieves env vars and makes Python boolean replacements"""
    val = os.environ.get(key, default)
    if val == 'True':
        val = True
    elif val == 'False':
        val = False
    return val

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

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = env_var("SECRET_KEY")

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = env_var("IS_DEBUG")

ALLOWED_HOSTS = [env_var("ALLOWED_HOSTS")]

# The person to contact on error when DEBUG=False
ADMINS = [(env_var("ADMIN_NAME"), env_var("ADMIN_EMAIL")),]

# Honor the 'X-Forwarded-Proto' header for request.is_secure()
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')

# Application definition

from multisite import SiteID
SITE_ID = SiteID(default=1)

ROOT_URLCONF = 'cloudmasterstudios.urls'

WSGI_APPLICATION = 'cloudmasterstudios.wsgi.application'

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

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

LANGUAGE_CODE = 'en'

TIME_ZONE = 'America/Toronto'

USE_I18N = True

USE_L10N = True

USE_TZ = True

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.8/howto/static-files/

STATIC_URL = '/static/'
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(DATA_DIR, 'media')
STATIC_ROOT = os.path.join(DATA_DIR, 'static')

STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'cloudmasterstudios', 'static'),
)

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'cloudmasterstudios', 'templates'),],
        'OPTIONS': {
            'context_processors': [
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
                'django.core.context_processors.i18n',
                'django.core.context_processors.debug',
                'django.core.context_processors.request',
                'django.core.context_processors.media',
                'django.core.context_processors.csrf',
                'django.core.context_processors.tz',
                'sekizai.context_processors.sekizai',
                'django.core.context_processors.static',
                'cms.context_processors.cms_settings',
                'aldryn_boilerplates.context_processors.boilerplate',
            ],
            'loaders': [
                'django.template.loaders.filesystem.Loader',
                'multisite.template_loader.Loader',
                'django.template.loaders.app_directories.Loader',
                'django.template.loaders.eggs.Loader',
                'aldryn_boilerplates.template_loaders.AppDirectoriesLoader',
            ],
        },
    },
]

MIDDLEWARE_CLASSES = [
    'htmlmin.middleware.HtmlMinifyMiddleware',
    'cms.middleware.utils.ApphookReloadMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.locale.LocaleMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'multisite.middleware.DynamicSiteMiddleware',
    'cms.middleware.user.CurrentUserMiddleware',
    'cms.middleware.page.CurrentPageMiddleware',
    'cms.middleware.toolbar.ToolbarMiddleware',
    'cms.middleware.language.LanguageCookieMiddleware',
    'htmlmin.middleware.MarkRequestMiddleware',
]

INSTALLED_APPS = [
    # Django & Django-CMS
    'djangocms_admin_style',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.admin',
    'django.contrib.sites',
    'django.contrib.sitemaps',
    'django.contrib.staticfiles',
    'django.contrib.messages',
    'cms',
    'menus',
    'sekizai',
    'treebeard',
    'djangocms_text_ckeditor',
    'djangocms_style',
    'djangocms_column',
    'filer',
    'easy_thumbnails',
    'cmsplugin_filer_image',
    'cmsplugin_filer_file',
    'cmsplugin_filer_folder',
    'cmsplugin_filer_teaser',
    'cmsplugin_filer_utils',
    'cmsplugin_filer_video',
    'djangocms_googlemap',
    'djangocms_inherit',
    'djangocms_link',
    'reversion',
    # Django-CMS Blogging
    'aldryn_apphooks_config',
    'aldryn_boilerplates',
    'aldryn_categories',
    'aldryn_newsblog',
    'aldryn_people',
    'aldryn_reversion',
    'aldryn_common',
    'parler',
    'sortedm2m',
    'taggit',
    'aldryn_disqus',
    # Third Party
    'multisite',
    'compressor',
    # Custom
    'cloudmasterstudios'
]

LANGUAGES = (
    ## Customize this
    ('en', gettext('en')),
    ('', gettext('')),
)

CMS_LANGUAGES = {
    ## Customize this
    1: [
        {
            'redirect_on_fallback': True,
            'hide_untranslated': False,
            'code': 'en',
            'public': True,
            'name': gettext('en'),
        },
        {
            'redirect_on_fallback': True,
            'hide_untranslated': False,
            'code': '',
            'public': True,
            'name': gettext(''),
        },
    ],
    'default': {
        'redirect_on_fallback': True,
        'hide_untranslated': False,
        'public': True,
    },
}

CMS_TEMPLATES = (
    ## Customize this
    ('fullwidth.html', 'Fullwidth'),
    ('sidebar_left.html', 'Sidebar Left'),
    ('sidebar_right.html', 'Sidebar Right')
)

CMS_PERMISSION = True

CMS_PLACEHOLDER_CONF = {}

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

DATABASES = {
    'default': {
        'CONN_MAX_AGE': 0,
        "ENGINE": "django.db.backends.postgresql_psycopg2"
    }
}
DATABASES['default'] = dj_database_url.config(default=env_var("DATABASE_URL"))

MIGRATION_MODULES = {
    'cmsplugin_filer_folder': 'cmsplugin_filer_folder.migrations_django',
    'cmsplugin_filer_video': 'cmsplugin_filer_video.migrations_django',
    'cmsplugin_filer_file': 'cmsplugin_filer_file.migrations_django',
    'cmsplugin_filer_image': 'cmsplugin_filer_image.migrations_django',
    'cmsplugin_filer_teaser': 'cmsplugin_filer_teaser.migrations_django',
}

THUMBNAIL_PROCESSORS = (
    'easy_thumbnails.processors.colorspace',
    'easy_thumbnails.processors.autocrop',
    'filer.thumbnail_processors.scale_and_crop_with_subject_location',
    'easy_thumbnails.processors.filters'
)

ALDRYN_BOILERPLATE_NAME='bootstrap3'

STATICFILES_FINDERS = [
  'django.contrib.staticfiles.finders.FileSystemFinder',
  'aldryn_boilerplates.staticfile_finders.AppDirectoriesFinder',
  'django.contrib.staticfiles.finders.AppDirectoriesFinder',
]

# # The cache connection to use for django-multisite.
# # Default: 'default'
# CACHE_MULTISITE_ALIAS = 'multisite'
#
# # The cache key prefix that django-multisite should use.
# # Default: '' (Empty string)
# CACHE_MULTISITE_KEY_PREFIX = ''
#
#
#
# CACHES = {
#     'default': { # (PROD/QA)
#         'BACKEND': 'django.core.cache.backends.memcached.PyLibMCCache',
#         'LOCATION': '127.0.0.1:11211',
#     },
#     'multisite': {
#         'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
#         'TIMEOUT': 60 * 60 * 24,  # 24 hours
#     },
# }
#
# # Django-CMS Caching
# # https://docs.django-cms.org/en/develop/how_to/caching.html
#
# CMS_CACHE_PREFIX = 'default'
bartmika commented 8 years ago

If it helps here is my requirements.txt file. Is the main library versions similar to when you got it wokring?

Babel==2.3.4
Django==1.8.13
Django-Select2==4.3.2
Pillow==3.2.0
Unidecode==0.04.19
YURL==0.13
aldryn-apphooks-config==0.2.7
aldryn-boilerplates==0.7.4
aldryn-categories==1.0.3
aldryn-common==1.0.3
aldryn-disqus==1.0.0
aldryn-newsblog==1.2.2
aldryn-people==1.2.1
aldryn-reversion==1.0.9
aldryn-translation-tools==0.2.1
argparse==1.4.0
backport-collections==0.1
beautifulsoup4==4.4.1
click==6.6
cmsplugin-filer==1.0.1
dj-database-url==0.4.1
django-appconf==1.0.2
django-appdata==0.1.5
django-classy-tags==0.7.2
django-cms==3.2.5
django-compressor==2.0
django-filer==1.2.0
django-formtools==1.0
django-htmlmin==0.9.1
django-mailgun==0.9.1
django-mptt==0.8.4
django-multisite==1.2.5
django-parler==1.6.3
django-phonenumber-field==1.1.0
django-polymorphic==0.8.1
django-reversion==1.8.7
django-sekizai==0.9.0
django-sortedm2m==1.3.0
django-taggit==0.19.1
django-treebeard==4.0.1
djangocms-admin-style==1.2.2
djangocms-column==1.6.0
djangocms-googlemap==0.4.0
djangocms-inherit==0.2.1
djangocms-installer==0.8.10
djangocms-link==1.7.2
djangocms-style==1.7.0
djangocms-text-ckeditor==2.9.3
easy-thumbnails==2.3
gunicorn==19.6.0
html5lib==0.9999999
idna==2.1
lxml==3.6.0
ordereddict==1.1
phonenumbers==7.4.2
phonenumberslite==7.4.2
psycopg2==2.6.1
python-dateutil==2.5.3
python-dotenv==0.5.1
python-slugify==1.2.0
pytz==2016.4
rcssmin==1.0.6
requests==2.10.0
requests-file==1.4
rjsmin==1.0.12
six==1.10.0
tldextract==2.0.1
tzlocal==1.2.2
yakky commented 8 years ago

@bartmika multisite must be added to INSTALLED_APPS and then you have to run python manage.py migrate

bartmika commented 8 years ago

Thanks, I'll close this.

yakky commented 8 years ago

Great! let me know if this middleware works for you

bartmika commented 8 years ago

Unfortatunely so many other errors occur I just decided to close this ticket and create new separate tickets. The problem is getting django-multisite working before I can test this library.

Perhaps maybe you can update README.rst to include the instructions you've used to setup that library before I try this libraryh?

yakky commented 8 years ago

I'm going to push a sample project with a setting based on yours as reference

bartmika commented 8 years ago

Any luck getting it to work?

rodolfomartinez commented 8 years ago

bump?

yakky commented 8 years ago

@bartmika @rodolfomartinez I'm working on the sample project right now. Hopefully I should be able to push it later today

rodolfomartinez commented 8 years ago

Awesome thank you!

On Sat, Jun 18, 2016 at 12:12 PM, Iacopo Spalletti <notifications@github.com

wrote:

@bartmika https://github.com/bartmika @rodolfomartinez https://github.com/rodolfomartinez I'm working on the sample project right now. Hopefully I should be able to push it later today

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/nephila/djangocms-multisite/issues/2#issuecomment-226950526, or mute the thread https://github.com/notifications/unsubscribe/AHMFGl5FWRd3q_uXHJmc9t3dAm36mUYmks5qNBjwgaJpZM4I1mox .

Sincerely, Rodolfo Martinez (519)521-3135 / (281)674-5103 Skype: rodolfo-reimar CEO The Shooting Star Press inc. www.LuchaComics.com

Be sure to follow @LuchaComics !

yakky commented 8 years ago

@bartmika @rodolfomartinez see https://github.com/yakky/multisite-example. It's based on the configuration above, except minor changes

bartmika commented 8 years ago

Thank you @yakky ! I will test this out and tell you my results.

bartmika commented 8 years ago

Hi @yakky,

I ran your sample project and I got your example working! This is great to see.

Was there something I did wrong in this project? (I'll investigate on my end though)

yakky commented 8 years ago

Template loader is my first guess. I'll check I can make it work