使用CKeditor将我在管理员中所做的渲染到我的实际HTML页面时遇到问题 我遵循了ckE的文档(collectstatic,makemigrations等)。 这就是我用ckeditor做的 admin page
,这就是它所显示的。 hmtl page
setting.py
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'web_app',
'ckeditor',
'ckeditor_uploader',
]
CKEDITOR_UPLOAD_PATH = 'uploads/'
# CKEditor Configuration Settings
CKEDITOR_CONFIGS = {
'default': {
# 'toolbar': 'Custom',
'width': '800px',
'height': 'auto',
# 'toolbar_Custom': [
# ['Bold', 'Italic', 'Underline'],
# ['NumberedList', 'BulletedList'],
# ],
}
}
STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "web_app/static"),
]
STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), "static_cdn")
MEDIA_URL = '/media/'
MEDIA_ROOT = BASE_DIR
models.py
from django.db import models
from datetime import datetime
from ckeditor.fields import RichTextField
# Create your models here.
class Article(models.Model):
title = models.CharField(max_length=200)
content = RichTextField()
published = models.DateTimeField("date published", default= datetime.now())
image = models.ImageField(upload_to='images/', default="")
urls.py(主要不是项目本身)
from django.contrib import admin
from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
path('', include('web_app.urls')),
path('admin/', admin.site.urls),
path('ckeditor/', include('ckeditor_uploader.urls')),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)