RichTextField在Wagtail 2.0中不可编辑Draftail

2024-09-28 03:19:57 发布

您现在位置:Python中文网/ 问答频道 /正文

我更新了我的网站(开发版)到wagtail 2.0,我的页面的所有RichTextField属性都是完全不可编辑的德拉菲尔.js. 我在我的设置.py公司名称:

WAGTAILADMIN_RICH_TEXT_EDITORS = {
    'default': {
        'WIDGET': 'wagtail.admin.rich_text.HalloRichTextArea'
    }
}

回到前者你好啊编辑器,它可以正常工作。但是当我删除它时,已经保存的内容不会被打印,也不再有编辑功能。以下是模型定义:

^{pr2}$

还有我的设置.py文件:

import os
from decouple import config

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

# 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 = config('SECRET_KEY')

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

ALLOWED_HOSTS = []

# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django_extensions',
    'django.contrib.sitemaps',

    'wagtail.contrib.forms',
    'wagtail.contrib.redirects',
    'wagtail.embeds',
    'wagtail.sites',
    'wagtail.users',
    'wagtail.snippets',
    'wagtail.documents',
    'wagtail.images',
    'wagtail.search',
    'wagtail.admin',
    'wagtail.core',

    'modelcluster',
    'taggit',

    'homepage',
    'blog',
]

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',

    'wagtail.core.middleware.SiteMiddleware',
    'wagtail.contrib.redirects.middleware.RedirectMiddleware',
]

ROOT_URLCONF = 'lsvwebsite.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [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.contrib.messages.context_processors.messages',
            ],
        },
    },
]

WSGI_APPLICATION = 'site.wsgi.application'

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

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': config('NAME_DB'),
        'USER': config('USER_DB'),
        'PASSWORD': config('PASSWORD_DB'),
        'HOST': config('HOST_DB'),
        'PORT': '',
    }
}


# Password validation
# https://docs.djangoproject.com/en/1.11/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.11/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.11/howto/static-files/

STATIC_URL = '/static/'
STATICFILES_DIRS = [
    os.path.join(BASE_DIR, "static"),
]

#media files
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')

#wagtail site name
WAGTAIL_SITE_NAME = 'Site Name'

WAGTAILADMIN_RICH_TEXT_EDITORS = {
    'default': {
        'WIDGET': 'wagtail.admin.rich_text.HalloRichTextArea'
    }
}

这看起来是个问题德拉菲尔.js编辑

编辑1:使用Firefox Quantum 58.0.2在web控制台中打印错误

TypeError: o.a.createElement is not a function    draftail.js:1:241051
TypeError: window.draftail is undefined    edit:560:1

编辑2:使用Opera51.0在web控制台中打印错误

draftail.js:1 Uncaught TypeError: o.a.createElement is not a function
    at Object.<anonymous> (draftail.js:1)
    at t (vendor.js:1)
    at Object.<anonymous> (draftail.js:1)
    at t (vendor.js:1)
    at Object.<anonymous> (draftail.js:1)
    at t (vendor.js:1)
    at window.webpackJsonp (vendor.js:1)
    at draftail.js:1
(index):560 Uncaught TypeError: Cannot read property 'initEditor' of  undefined
    at (index):560
rangy-core.js:80 [Deprecation] The behavior that Selection.addRange() merges existing Range and the specified Range was removed. See  https://www.chromestatus.com/features/6680566019653632 for more details.
(anonymous) @ rangy-core.js:80

Tags: pathdjangonamehttpscomauthconfigos
2条回答

所以,首先我试着清理缓存,但没用。 然后我记得我习惯于设置firefox在它关闭时自动清除缓存,所以我检查了我的firefox设置,它确实是这样设置的。然后,我尝试了@fixgoats解决方案,我清除了我自己没有创建的静态文件,并运行collectstatic,它不起作用。我记得我不应该在dev环境中运行collectstatic,所以我删除了它们,但没有再次运行collectstatic,它不起作用,所以我清除了缓存(因为在此过程中我没有关闭firefox),它就起作用了。在

我的猜测是,我把过时的静态文件直接存储在dev static目录中,而firefox正在使用和缓存这些过时的文件(一个问题隐藏另一个问题)。现在,一切都很好,非常感谢你们。在

我相信我也有同样的问题,至少错误信息的标题是一样的,描述也很相似。对我起作用的是删除静态wagtailadmin javascript目录并再次运行collectstatic。但我还是不知道到底是什么导致了这个错误。在

相关问题 更多 >

    热门问题