Reputation: 1
I am getting the problem of not being able to add some native django cms plugins in my templates.
I keep getting the message Please correct the error below.
I tried to debug it but I am new to Django and I can't see where I went wrong.
Can it be a problem with Django cms it self?
With no errors showing in the form.
This is my settings.py
from pathlib import Path
import os
import dj_database_url
from django_storage_url import dsn_configured_storage_class
from django.utils.translation import gettext_lazy as _
gettext = lambda s: s
# 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'),]
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'
LOGGING = {
"version": 1,
"disable_existing_loggers": False,
"handlers": {
"file": {
"level": "ERROR",
"class": "logging.FileHandler",
"filename": "/debug.log",
},
"console": {
"class": "logging.StreamHandler",
},
},
"loggers": {
"django": {
"handlers": ["file", "console"],
"level": "ERROR",
"propagate": True,
},
},
}
# 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',
'django.contrib.sitemaps',
# 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',
'form_designer',
'form_designer.contrib.cms_plugins.form_designer_form',
'cookiebanner',
'debug_toolbar',
]
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',
'debug_toolbar.middleware.DebugToolbarMiddleware',
'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 main template for homepage and rest
('index.html', 'TechnoSite template'),
('homepage.html', 'Home page'),
('blog.html', 'Blog detail page'),
# a minimal template to get started with
('minimal.html', 'Minimal template'),
]
WSGI_APPLICATION = 'backend.wsgi.application'
# CookieBanner settings
COOKIEBANNER = {
"groups": [
{
"id": "essential",
"name": _("Essential"),
"description": _("Essential cookies allow this page to work."),
"cookies": [
{
"pattern": "cookiebanner",
"description": _("Meta cookie for the cookies that are set."),
},
{
"pattern": "csrftoken",
"description": _("This cookie prevents Cross-Site-Request-Forgery attacks."),
},
{
"pattern": "sessionid",
"description": _("This cookie is necessary to allow logging in, for example."),
},
],
},
{
"id": "analytics",
"name": _("Analytics"),
"optional": True,
"cookies": [
{
"pattern": "_pk_.*",
"description": _("Matomo cookie for website analysis."),
},
],
},
],
}
# 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)}
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'),
('nl', 'Netherlands'),
('ar', 'Arabic'),
]
CMS_LANGUAGES = {
1: [
{
'code': 'en',
'name': gettext('English'),
'fallbacks': ['nl', 'ar'],
'public': True,
'hide_untranslated': True,
'redirect_on_fallback': False,
},
{
'code': 'nl',
'name': gettext('Nederlands'),
'fallbacks': ['en', 'ar'],
'public': True,
},
{
'code': 'ar',
'name': gettext('العربية'),
'fallbacks': ['en', 'nl'],
'public': True,
},
],
'default': {
'fallbacks': ['en', 'ar', 'nl'],
'redirect_on_fallback': True,
'public': True,
'hide_untranslated': False,
}
}
if DEBUG:
import socket # only if you haven't already imported this
hostname, _, ips = socket.gethostbyname_ex(socket.gethostname())
INTERNAL_IPS = [ip[: ip.rfind(".")] + ".1" for ip in ips] + ["127.0.0.1", "10.0.2.2"]
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
# These are settings for remote storage (like s3 bucket)
# 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/')
# CSRF Settings
CSRF_TRUSTED_ORIGINS = []
# Mailing settings
EMAIL_PORT =
EMAIL_HOST =
EMAIL_USE_TLS = True
EMAIL_HOST_USER =
EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_HOST_PASSWORD')
SITE_ID = 1
I tried to use the minimal template that comes with the getting started project but no use.
Upvotes: 0
Views: 53
Reputation: 208
If you are running locally on your own computer you might see more details in the terminal that you used to start the django test server.
The error that you are seeing in the frontend "Please correct the error below" is indicating that the form data cant be saved because some fields could not be validated.
As #Fabian wrote, also try another plugin, see if its a general problem or just something specific to the Row Plugin.
Upvotes: 0