Django CMS pages not visible after server restart - django-cms

I've been using django-cms to build a simple website for my GF. I was editing the base template and for some reason my changes were not going through, so I restarted the nginx server script only to find out to my horror, that I can't see any of the page content anymore, only their names in the tree in the admin interface. If I try to go to a page, it claims the page does not exist.
I thought maybe there is something wrong with the setup so I ran fix-tree and migrate (which might have been an error on my part) and now even the page names are not visible anymore in the admin interface. The pages and their contents are in the database, but they are not accessible anymore.
Has anyone run into a similar issue? What could be a possible cause / solution for this? Any ideas where to look
My guess is that something was wrong with the setup or perhaps I had a wrong version of some package and then I didn't run into trouble until I restarted.
I would love to have all those pages back especially that they still exist in the DB. Will be eternally grateful for any help.
EDIT
I just tried creating a new page. I was able to do this without any errors, the page is visible in the database but it is not visible in on the "Pages" page and the page slug gives an 404 error.
EDIT 2
Here's the requirements.txt
aldryn-apphooks-config==0.2.7
aldryn-boilerplates==0.7.4
aldryn-bootstrap3==1.0.10
aldryn-categories==1.0.3
aldryn-common==1.0.4
aldryn-newsblog==1.2.4
aldryn-people==1.2.1
aldryn-reversion==1.0.9
aldryn-style==1.1.1
aldryn-translation-tools==0.2.1
aldryn-video==1.0.0
Babel==2.3.4
backport-collections==0.1
beautifulsoup4==4.4.1
dj-database-url==0.4.1
Django==1.8.15
django-appconf==1.0.2
django-appdata==0.1.5
django-classy-tags==0.8.0
django-cms==3.2.5
django-durationfield==0.5.2
django-filer==1.2.4
django-formtools==1.0
django-mptt==0.8.6
django-parler==1.6.5
django-phonenumber-field==1.1.0
django-polymorphic==0.8.1
django-reversion==1.8.7
django-sekizai==0.10.0
Django-Select2==4.3.2
django-sortedm2m==1.3.2
django-taggit==0.21.2
django-treebeard==4.0.1
djangocms-admin-style==1.2.3
djangocms-attributes-field==0.1.1
djangocms-column==1.6.0
djangocms-file==1.0
djangocms-googlemap==0.5.1
djangocms-inherit==0.2.1
djangocms-installer==0.8.7
djangocms-link==1.8.2
djangocms-picture==0.2.0
djangocms-style==1.7.0
djangocms-teaser==0.2.0
djangocms-text-ckeditor==3.1.0
djangocms-video==1.0.0
easy-thumbnails==2.3
gevent==1.1rc3
greenlet==0.4.9
gunicorn==18.0
html5lib==0.9999999
jsonfield==1.0.3
lxml==3.6.4
micawber==0.3.3
phonenumbers==7.5.2
phonenumberslite==7.5.2
Pillow==3.3.1
psycopg2==2.6.1
python-dateutil==2.5.3
python-slugify==1.2.0
pytz==2016.6.1
six==1.10.0
tzlocal==1.2.2
Unidecode==0.4.19
virtualenv==15.0.1
webencodings==0.5
YURL==0.13
And here's the settings file:
import os
gettext = lambda s: s
DATA_DIR = os.path.dirname(os.path.dirname(__file__))
"""
Django settings for anninsivut project.
Generated by 'django-admin startproject' using Django 1.8.14.
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__)))
# 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 = 'VERY SECRET'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = ['.site.com', ]
# Application definition
ROOT_URLCONF = 'anninsivut.urls'
WSGI_APPLICATION = 'anninsivut.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 = 'Europe/Amsterdam'
USE_I18N = False
USE_L10N = False
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, 'anninsivut', 'media')
STATIC_ROOT = os.path.join(DATA_DIR, 'anninsivut', 'static')
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'anninsivut', 'common_static'),
)
SITE_ID = 1
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'anninsivut', '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',
'django.template.loaders.app_directories.Loader',
'django.template.loaders.eggs.Loader',
'aldryn_boilerplates.template_loaders.AppDirectoriesLoader',
],
},
},
]
MIDDLEWARE_CLASSES = (
# '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'
)
INSTALLED_APPS = (
'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',
'djangocms_file',
'djangocms_googlemap',
'djangocms_inherit',
'djangocms_link',
'djangocms_picture',
'djangocms_teaser',
'aldryn_video',
'reversion',
'aldryn_apphooks_config',
'aldryn_boilerplates',
'aldryn_categories',
'aldryn_common',
'aldryn_translation_tools',
'aldryn_newsblog',
'aldryn_people',
'aldryn_reversion',
'aldryn_bootstrap3',
'parler',
'sortedm2m',
'taggit',
'easy_thumbnails',
'filer',
'anninsivut'
)
LANGUAGES = (
## Customize this
('en', gettext('en')),
)
ALDRYN_BOILERPLATE_NAME = 'bootstrap3'
STATICFILES_FINDERS = [
'django.contrib.staticfiles.finders.FileSystemFinder',
'aldryn_boilerplates.staticfile_finders.AppDirectoriesFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
]
CMS_LANGUAGES = {
## Customize this
1: [
{
'name': gettext('en'),
'redirect_on_fallback': True,
'code': 'en',
'public': True,
'hide_untranslated': False,
},
],
'default': {
'redirect_on_fallback': True,
'hide_untranslated': False,
'public': True,
},
}
THUMBNAIL_PROCESSORS = (
'easy_thumbnails.processors.colorspace',
'easy_thumbnails.processors.autocrop',
# 'easy_thumbnails.processors.scale_and_crop', # disable this one
'filer.thumbnail_processors.scale_and_crop_with_subject_location',
'easy_thumbnails.processors.filters',
)
CMS_TEMPLATES = (
## Customize this
('page.html', 'Page'),
('feature.html', 'Page with Feature')
)
CMS_PERMISSION = True
CMS_PLACEHOLDER_CONF = {}
DATABASES = {
'default': {
'CONN_MAX_AGE': 0,
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'HOST': 'localhost',
'NAME': 'anninsivut_DB',
'PASSWORD': 'password',
'PORT': '',
'USER': 'user'
}
}
DEFAULT_FROM_EMAIL = 'name#domain.com'
SERVER_EMAIL = 'name#domain.com'
ADMINS = (
('Your name', 'your email address'),
)
MIGRATION_MODULES = {
}
#Paulo Thanks for asking for these. Now that I looked at the requirements and settings file, I see that the requirements file I had on my local Pycharm dir had not synced with the one on the server. At some point I must've accidentally upgraded to Django 1.9 in the venv of the server. Now I guess that when I restarted that's when the Django-CMS picked up the change and lost the page contents. Then when I saw the loss and downgraded back to 1.8, that's when I lost the page names as well on the pages tree. I'll start by going through the changes between the two and also see if the packages are up to date with what they should be.

OK I managed to fix. After stepping through the code in the debugger in Pycharm, I realized I accidentally commented out the
LANGUAGE_CODE = 'en'
line in settings with made Django revert back to LANGUAGE_CODE = 'en-us', and that why it couldn't find the pages.
I also had a syncing problem between PyCharm and the deployment server, which is why the LANGUAGE_CODE = 'en' was not commented out in the settings.py I posted here.
So in short:
TIL that the language code must match in both
LANGUAGE_CODE = 'en'
and
CMS_LANGUAGES = {
1: [
{
'name': gettext('en'),
'redirect_on_fallback': True,
'code': 'en',
'public': True,
'hide_untranslated': False,
},
],
'default': {
'redirect_on_fallback': True,
'hide_untranslated': False,
'public': True,
},
}

Related

Django cms filer fails to upload file

While trying to upload a file using django cms filer I am getting the following error
`*Internal Server Error: /admin/filer/clipboard/operations/upload/1/
Traceback (most recent call last):
File "/home/kvint/temp/temp/django-cms-quickstart/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "/home/kvint/temp/temp/django-cms-quickstart/venv/lib/python3.10/site-packages/django/core/handlers/base.py", line 181, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/kvint/temp/temp/django-cms-quickstart/venv/lib/python3.10/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
return view_func(*args, **kwargs)
File "/home/kvint/temp/temp/django-cms-quickstart/venv/lib/python3.10/site-packages/filer/admin/clipboardadmin.py", line 112, in ajax_upload
file_obj.save()
File "/home/kvint/temp/temp/django-cms-quickstart/venv/lib/python3.10/site-packages/filer/models/imagemodels.py", line 66, in save
super().save(*args, **kwargs)
File "/home/kvint/temp/temp/django-cms-quickstart/venv/lib/python3.10/site-packages/filer/models/abstract.py", line 107, in save
super().save(*args, **kwargs)
File "/home/kvint/temp/temp/django-cms-quickstart/venv/lib/python3.10/site-packages/filer/models/filemodels.py", line 279, in save
super().save(*args, **kwargs)
File "/home/kvint/temp/temp/django-cms-quickstart/venv/lib/python3.10/site-packages/polymorphic/models.py", line 87, in save
return super().save(*args, **kwargs)
File "/home/kvint/temp/temp/django-cms-quickstart/venv/lib/python3.10/site-packages/django/db/models/base.py", line 726, in save
self.save_base(using=using, force_insert=force_insert,
File "/home/kvint/temp/temp/django-cms-quickstart/venv/lib/python3.10/site-packages/django/db/models/base.py", line 762, in save_base
parent_inserted = self._save_parents(cls, using, update_fields)
File "/home/kvint/temp/temp/django-cms-quickstart/venv/lib/python3.10/site-packages/django/db/models/base.py", line 791, in _save_parents
updated = self._save_table(
File "/home/kvint/temp/temp/django-cms-quickstart/venv/lib/python3.10/site-packages/django/db/models/base.py", line 868, in _save_table
results = self._do_insert(cls._base_manager, using, fields, returning_fields, raw)
File "/home/kvint/temp/temp/django-cms-quickstart/venv/lib/python3.10/site-packages/django/db/models/base.py", line 906, in _do_insert
return manager._insert(
File "/home/kvint/temp/temp/django-cms-quickstart/venv/lib/python3.10/site-packages/django/db/models/manager.py", line 85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/home/kvint/temp/temp/django-cms-quickstart/venv/lib/python3.10/site-packages/django/db/models/query.py", line 1270, in _insert
return query.get_compiler(using=using).execute_sql(returning_fields)
File "/home/kvint/temp/temp/django-cms-quickstart/venv/lib/python3.10/site-packages/django/db/models/sql/compiler.py", line 1409, in execute_sql
for sql, params in self.as_sql():
File "/home/kvint/temp/temp/django-cms-quickstart/venv/lib/python3.10/site-packages/django/db/models/sql/compiler.py", line 1352, in as_sql
value_rows = [
File "/home/kvint/temp/temp/django-cms-quickstart/venv/lib/python3.10/site-packages/django/db/models/sql/compiler.py", line 1353, in <listcomp>
[self.prepare_value(field, self.pre_save_val(field, obj)) for field in fields]
File "/home/kvint/temp/temp/django-cms-quickstart/venv/lib/python3.10/site-packages/django/db/models/sql/compiler.py", line 1353, in <listcomp>
[self.prepare_value(field, self.pre_save_val(field, obj)) for field in fields]
File "/home/kvint/temp/temp/django-cms-quickstart/venv/lib/python3.10/site-packages/django/db/models/sql/compiler.py", line 1304, in pre_save_val
return field.pre_save(obj, add=True)
File "/home/kvint/temp/temp/django-cms-quickstart/venv/lib/python3.10/site-packages/django/db/models/fields/files.py", line 301, in pre_save
file.save(file.name, file.file, save=False)
File "/home/kvint/temp/temp/django-cms-quickstart/venv/lib/python3.10/site-packages/filer/fields/multistorage_file.py", line 120, in save
super().save(name, content, save)
File "/home/kvint/temp/temp/django-cms-quickstart/venv/lib/python3.10/site-packages/easy_thumbnails/files.py", line 643, in save
super().save(name, content, *args, **kwargs)
File "/home/kvint/temp/temp/django-cms-quickstart/venv/lib/python3.10/site-packages/django/db/models/fields/files.py", line 87, in save
name = self.field.generate_filename(self.instance, name)
File "/home/kvint/temp/temp/django-cms-quickstart/venv/lib/python3.10/site-packages/django/db/models/fields/files.py", line 320, in generate_filename
return self.storage.generate_filename(filename)
File "/home/kvint/temp/temp/django-cms-quickstart/venv/lib/python3.10/site-packages/django/core/files/storage.py", line 108, in generate_filename
return os.path.normpath(os.path.join(dirname, self.get_valid_name(filename)))
File "/home/kvint/temp/temp/django-cms-quickstart/venv/lib/python3.10/site-packages/django_storage_url/backends/not_implemented.py", line 14, in get_valid_name
raise NotImplementedError
NotImplementedError
[20/Feb/2023 09:27:05] "POST /admin/filer/clipboard/operations/upload/1/?qqfile=img0.jpg HTTP/1.1" 500 187409
[20/Feb/2023 09:27:05] "GET /admin/filer/folder/1/list/?order_by=-modified_at HTTP/1.1" 200 16717
*`
I used the default installation of DjangoCMS from git#github.com:django-cms/django-cms-quickstart.git
I only modified the DATABASE settings so it uses sqlite
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
Here is my full settings file
from pathlib import Path
import os
import dj_database_url
from django_storage_url import dsn_configured_storage_class
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.environ.get('SECRET_KEY', '<a string of random characters>')
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = os.environ.get('DEBUG') == "True"
ALLOWED_HOSTS = [os.environ.get('DOMAIN'),]
DEBUG = True
ALLOWED_HOSTS = ["localhost",]
if DEBUG:
ALLOWED_HOSTS = ["*",]
# Redirect to HTTPS by default, unless explicitly disabled
#SECURE_SSL_REDIRECT = os.environ.get('SECURE_SSL_REDIRECT') != "False"
X_FRAME_OPTIONS = 'SAMEORIGIN'
# Application definition
INSTALLED_APPS = [
'backend',
# optional, but used in most projects
'djangocms_admin_style',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'whitenoise.runserver_nostatic', # http://whitenoise.evans.io/en/stable/django.html#using-whitenoise-in-development
'django.contrib.staticfiles',
'django.contrib.sites',
# key django CMS modules
'cms',
'menus',
'treebeard',
'sekizai',
# Django Filer - optional, but used in most projects
'filer',
'easy_thumbnails',
# the default CKEditor - optional, but used in most projects
'djangocms_text_ckeditor',
# some content plugins - optional, but used in most projects
'djangocms_file',
'djangocms_icon',
'djangocms_picture',
'djangocms_style',
'djangocms_googlemap',
'djangocms_video',
# optional django CMS Frontend modules
'djangocms_frontend',
'djangocms_frontend.contrib.accordion',
'djangocms_frontend.contrib.alert',
'djangocms_frontend.contrib.badge',
'djangocms_frontend.contrib.card',
'djangocms_frontend.contrib.carousel',
'djangocms_frontend.contrib.collapse',
'djangocms_frontend.contrib.content',
'djangocms_frontend.contrib.grid',
'djangocms_frontend.contrib.jumbotron',
'djangocms_frontend.contrib.link',
'djangocms_frontend.contrib.listgroup',
'djangocms_frontend.contrib.media',
'djangocms_frontend.contrib.image',
'djangocms_frontend.contrib.tabs',
'djangocms_frontend.contrib.utilities',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
'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',
'django.middleware.locale.LocaleMiddleware',
'cms.middleware.user.CurrentUserMiddleware',
'cms.middleware.page.CurrentPageMiddleware',
'cms.middleware.toolbar.ToolbarMiddleware',
'cms.middleware.language.LanguageCookieMiddleware',
]
ROOT_URLCONF = 'backend.urls'
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',
'django.template.context_processors.media',
'django.template.context_processors.csrf',
'django.template.context_processors.tz',
'django.template.context_processors.i18n',
'cms.context_processors.cms_settings',
'sekizai.context_processors.sekizai',
],
},
},
]
THUMBNAIL_PROCESSORS = (
'easy_thumbnails.processors.colorspace',
'easy_thumbnails.processors.autocrop',
#'easy_thumbnails.processors.scale_and_crop',
'filer.thumbnail_processors.scale_and_crop_with_subject_location',
'easy_thumbnails.processors.filters',
)
CMS_TEMPLATES = [
# a minimal template to get started with
('minimal.html', 'Minimal template'),
# optional templates that extend base.html, to be used with Bootstrap 5
('bootstrap5.html', 'Bootstrap 5 Demo'),
# serving static files with whitenoise demo
('whitenoise-static-files-demo.html', 'Static File Demo'),
]
WSGI_APPLICATION = 'backend.wsgi.application'
# Database
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases
# Configure database using DATABASE_URL; fall back to sqlite in memory when no
# environment variable is available, e.g. during Docker build
#DATABASE_URL = os.environ.get('DATABASE_URL', 'sqlite://:memory:')
#DATABASES = {'default': dj_database_url.parse(DATABASE_URL)}
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
# Password validation
# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators
if not DEBUG:
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/3.1/topics/i18n/
LANGUAGE_CODE = 'en'
LANGUAGES = [
('en', 'English'),
]
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.1/howto/static-files/
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles_collected')
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
# Media files
# DEFAULT_FILE_STORAGE is configured using DEFAULT_STORAGE_DSN
# read the setting value from the environment variable
DEFAULT_STORAGE_DSN = os.environ.get('DEFAULT_STORAGE_DSN')
# dsn_configured_storage_class() requires the name of the setting
DefaultStorageClass = dsn_configured_storage_class('DEFAULT_STORAGE_DSN')
# Django's DEFAULT_FILE_STORAGE requires the class name
DEFAULT_FILE_STORAGE = 'backend.settings.DefaultStorageClass'
# only required for local file storage and serving, in development
MEDIA_URL = 'media/'
MEDIA_ROOT = os.path.join('/data/media/')
SITE_ID = 1

Customizing css file in django-oscar using less

I am fairly new to django oscar and only have basic understanding of website front end.
I want to change the styles.css in django oscar. I have tried to change directly in styles.css but somehow when I refresh the localhost detects no changes (default css).
I've tried to change the less file, install npm, install less and change the setting into OSCAR_USE_LESS = True. The localhost didn't even render the css file at all, only the template.
When I write the command make css in root directory, following error occurred even though I've installed less.
make: *** No rule to make target `css'. Stop.
so I really don't know what is wrong with my setting or installed apps.
Settings are
import os
import oscar
# Path helper - going into /Users/dion/Dev/dioncoffee/x
location = lambda x: os.path.join(
os.path.dirname(os.path.dirname(os.path.realpath(__file__))), x)
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '=%*t%wzzw^hs5l2o#oq2ae-*&wde0bko4!hxl%=uqb$!5po$tt'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
from oscar import get_core_apps
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.flatpages',
'django_extensions',
'compressor',
#'apps.gateway', # For allowing dashboard access
'widget_tweaks',
] + get_core_apps(
['apps.promotions']
)
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',
'oscar.apps.basket.middleware.BasketMiddleware',
'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
]
ROOT_URLCONF = 'dioncoffee.urls'
from oscar import OSCAR_MAIN_TEMPLATE_DIR
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
location('dioncoffee/templates'),
oscar.OSCAR_MAIN_TEMPLATE_DIR,
],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.template.context_processors.i18n',
'django.contrib.messages.context_processors.messages',
'oscar.apps.search.context_processors.search_form',
'oscar.apps.promotions.context_processors.promotions',
'oscar.apps.checkout.context_processors.checkout',
'oscar.apps.customer.notifications.context_processors.notifications',
'oscar.core.context_processors.metadata',
],
},
},
]
WSGI_APPLICATION = 'dioncoffee.wsgi.application'
# Database
# https://docs.djangoproject.com/en/2.1/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'dioncoffee',
'USER': 'dion',
'PASSWORD': '',
'HOST': '127.0.0.1',
'PORT': '',
}
}
# Password validation
# https://docs.djangoproject.com/en/2.1/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',
},
]
AUTHENTICATION_BACKENDS = (
'oscar.apps.customer.auth_backends.EmailBackend',
'django.contrib.auth.backends.ModelBackend',
)
# Internationalization
# https://docs.djangoproject.com/en/2.1/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.simple_backend.SimpleEngine',
},
}
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.1/howto/static-files/
# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = location("public/media")
STATIC_ROOT = location('public/static')
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash if there is a path component (optional in other cases).
# Examples: "http://media.lawrence.com", "http://example.com/media/"
MEDIA_URL = '/media/'
STATIC_URL = '/static/'
# /Users/dion/Dev/dioncoffee/static/
STATICFILES_DIRS = (
location('static'),
)
from oscar.defaults import *
OSCAR_DEFAULT_CURRENCY = 'EUR'
OSCAR_CURRENCY_FORMAT = {
'USD': {
'currency_digits': False,
'format_type': "accounting",
},
'EUR': {
'format': u'#,##0\xa0ยค',
}
}
USE_LESS = True
COMPRESS_ENABLED = False
COMPRESS_PRECOMPILERS = (
('text/less', 'lessc {infile} {outfile}'),
)
COMPRESS_OFFLINE_CONTEXT = {
'STATIC_URL': 'STATIC_URL',
'use_less': USE_LESS,
}
My directory files
And I am using python 3.6.5.
make css is intended only for development on Oscar itself - it will not work in your project. I can't see why the USE_LESS approach would fail if you are in debug mode though.
That said, I think you are better off overriding the CSS rather than relying on USE_LESS which is likely to be removed completely in the future, and is only really intended for development.
You should be able to override the CSS if you are putting in the right place.
If you have your CSS inside an app, then it needs to go inside app_dir/static/oscar/css/style.css and you need to have 'django.contrib.staticfiles.finders.AppDirectoriesFinder' in the STATICFILES_FINDERS setting.
Alternatively if you have a separate directory for static files then you need to include 'django.contrib.staticfiles.finders.FileSystemFinder' in the setting, and also specify STATICFILES_DIRS to tell Django where this directory is.

change background color of placeholder django cms

I want user to be able change colors of placeholders.
I try to install djangocms-css-background.
I fallowed these steps https://pypi.python.org/pypi/djangocms-css-background/1.0.4
at first i had error : "no module found djangocms-css-background" When i ran python manage migrate.
Somehow i fixed an error. But im stucked with this one
djangocms-css-background.CssBackground.cmsplugin_ptr: (fields.E306) The name 'djangocms-css-background_cssbackground' is invalid related_name for field CssBackground.cmsplugin_ptr
HINT: Related name must be a valid Python identifier or end with a '+'
settings.py
import os
gettext = lambda s: s
DATA_DIR = os.path.dirname(os.path.dirname(__file__))
"""
Django settings for mysite project.
Generated by 'django-admin startproject' using Django 1.8.15.
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__)))
# 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 = '6!we3efe11p$%8x#r3y_)pioj5&-%%$g5ezmu2m_dm(^_f^2m8'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
ROOT_URLCONF = 'mysite.urls'
WSGI_APPLICATION = 'mysite.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 = 'Europe/Ljubljana'
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, 'mysite', 'static'),
)
SITE_ID = 1
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'mysite', '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'
],
'loaders': [
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
'django.template.loaders.eggs.Loader'
],
},
},
]
MIDDLEWARE_CLASSES = (
'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'
)
INSTALLED_APPS = (
'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',
'filer',
'easy_thumbnails',
'djangocms_column',
'djangocms_link',
'cmsplugin_filer_file',
'cmsplugin_filer_folder',
'cmsplugin_filer_image',
'cmsplugin_filer_utils',
'djangocms_style',
'djangocms_snippet',
'djangocms_googlemap',
'djangocms_video',
'mysite',
'djangocms-css-background'
)
LANGUAGES = (
## Customize this
('en', gettext('en')),
)
CMS_LANGUAGES = {
## Customize this
'default': {
'public': True,
'hide_untranslated': False,
'redirect_on_fallback': True,
},
1: [
{
'public': True,
'code': 'en',
'hide_untranslated': False,
'name': gettext('en'),
'redirect_on_fallback': True,
},
],
}
CMS_TEMPLATES = (
## Customize this
('fullwidth.html', 'Fullwidth'),
('sidebar_left.html', 'Sidebar Left'),
('sidebar_right.html', 'Sidebar Right'),
('template_1.html', 'Template One'),
('template_2.html', 'Template Two')
)
CMS_PERMISSION = True
CMS_PLACEHOLDER_CONF = {}
DATABASES = {
'default': {
'CONN_MAX_AGE': 0,
'ENGINE': 'django.db.backends.sqlite3',
'HOST': 'localhost',
'NAME': 'project.db',
'PASSWORD': '',
'PORT': '',
'USER': ''
}
}
MIGRATION_MODULES = {
}
THUMBNAIL_PROCESSORS = (
'easy_thumbnails.processors.colorspace',
'easy_thumbnails.processors.autocrop',
'filer.thumbnail_processors.scale_and_crop_with_subject_location',
'easy_thumbnails.processors.filters'
)
i tried
python manage.py makemigrations djangocms-css-background
and i get same error
I see in readme syntax with +. Wherever i put +, I get an error "invalid sintax".
I'm using django 1.10, python 2.7
If someone have any suggestion or other idea to do this.
Thanks for help
The person who has created the djangocms-css-background package has named the app poorly, as python does not like file names to contain a hyphen (-). They should have named the top level directory in the package as djangocms_css_background.
The repository and pypi package are fine to contain a hyphen, it's just the app directory.
This is why you're having problems.
That package is depreciated and no longer maintained and having a quick scan through has a few problems.
You could fork the package, resolve the problems, then install your version of the package.
But what exactly are you trying to do as I'm not overly clear from the question. If you'd like to be able to change the background colour of a container (like this app allows you to), it's really quite simple to recreate. I'm just not 100% what you mean by the "background colour of a placeholder".
If you provide more information, I may be able to help you further.

Can't configure karma to use karma-spec-reporter

In my karma.conf.js
plugins : [
'karma-phantomjs-launcher',
'karma-angular-filesort',
'karma-coverage',
'karma-jasmine',
'karma-ng-html2js-preprocessor',
'karma-spec-reporter',
],
coverageReporter: {
type : 'html',
dir : 'coverage/'
},
specReporter: {
maxLogLines: 10,
suppressPassed: false,
suppressFailed: false,
suppressSkipped: false,
suppressErrorSummary: false
},
// reporters: ['progress']
reporters: ['spec']
Yet when I run my tests (gulp test), the output continues to be the same as when karma used the 'progress' reporter.
What am I missing?

Configuring autogrow plugin with djangocms-text-ckeditor

I am trying to use the autogrow plugin for ckeditor. As I am new to django and ckeditor I am having trouble with configuration. My settings are not being recognized. Below is a list of steps. I have seen reference to having to build ckeditor over again. I do not know if this is needed.
Platform: Ubuntu, django-cms 3 beta, djangocms-text-ckeditor (installed used pip in virtualenv), python 2.7.
I do not know exactly what I need to do, but I changed the following anyway.
S1. In project's settings.py, added
CKEDITOR_SETTINGS = getattr(settings, 'CKEDITOR_SETTINGS', {
'config.autoGrow_onStartup': True,
'config.autoGrow_minHeight': 200,
'config.autoGrow_maxHeight': 400,
})
S2. In ../site-packages/django_text_ckeditor/static/ckeditor/config.js, edited
CKEDITOR.editorConfig = function( config ) {
// Define changes to default configuration here. For example:
// config.language = 'fr';
// config.uiColor = '#AADC6E';
config.autoGrow_onStartup = true;
config.autoGrow_minHeight = 2000;
config.autoGrow_maxHeight = 4000;
};
S3. Added the autogrow plugin folder to
"../site-packages/django_text_ckeditor/static/ckeditor/plugins/autogrow"
S4. Modified line 45 of
"../site-packages/django_text_ckeditor/static/js/cms.ckeditor.js"
'extraPlugins': 'cmsplugins, autogrow'
S5. Added an extra statement after line 58 of
"../site-packages/django_text_ckeditor/static/js/cms.ckeditor.js"
// this is line 58
CKEDITOR.plugins.addExternal('cmsplugins', settings.static_url + 'ckeditor_plugins/cmsplugins/');
// this is the added line
CKEDITOR.plugins.addExternal('autogrow', settings.static_url + 'ckeditor/plugins/autogrow');
Do not know what else to do? Thoughts? Advice?
I'am using standard django-ckeditor from here: https://github.com/django-ckeditor/django-ckeditor
Your Step S2 and S4 and S5 are not needed. It makes no sens to modify the source of ckeditor. Just download the autogrow plugin from http://ckeditor.com/addon/autogrow and config with settings.py:
CKEDITOR_CONFIGS = {
'default': {
'autoGrow_onStartup': True,
'autoGrow_minHeight': 100,
'autoGrow_maxHeight': 650,
'extraPlugins': 'autogrow',
'toolbar': 'Custom',
'toolbar_Custom': [
['Bold', 'Italic', 'Underline'],
['Format'],
#['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'],
['Link', 'Unlink'],
['RemoveFormat', 'Source']
],
}
}

Resources