我已经按照文档中的说明在 django 1.5 上安装了 django-ckeditor 。如文档中所述,我已将应用程序 models.py 中的 TextField 更改为 RichTextField。但是我仍然在 Django 管理员而不是 ckeditor 中看到空白文本区域。 这个问题是 3 年前提出的,但没有一个答案对我有用。当我得到页面时,ckeditor.js 加载得很好。有什么建议么?我的应用名称是新闻源。
模型.py:
from cms.models.pluginmodel import CMSPlugin
from cms.models import Page
from django.db import models
from time import time
from ckeditor.fields import RichTextField
def get_upload_file_name(instance, filename):
return "uploaded_files/%s_%s" % (str(time()).replace('.','_'),filename)
# Create your models here.
class NewsFeed (models.Model):
title = models.CharField(('Feed Name'),max_length=200,help_text=('Feed name is visible only in edit mode'))
publisher = models.CharField(('Publisher'),max_length=200)
def __unicode__(self):
return self.title
def get_absolute_url(self):
return "/newsfeed/get/%i" % self.id
class NewsItem(models.Model):
feed_id = models.ForeignKey(NewsFeed)
title = models.CharField(('Title'),max_length=200)
subtitle = models.CharField(('Sub-Title'),max_length=350,help_text=('Subtitles are displayed in auto-scroller and has max characters of 350'))
#body = models.TextField(('Content'),blank=True,help_text=('Content is NOT visible in auto-scroller !'))
body = RichTextField()
url = models.URLField(("Link"), blank=True, null=True)
page_link = models.ForeignKey(Page, verbose_name=("page"), blank=True, null=True, help_text=("A link to a page has priority over a text link."))
pub_date = models.DateTimeField('Publish Date')
is_published = models.BooleanField(('Published'), default=False)
class NewsFeedPlugin(CMSPlugin):
newsfeed = models.ForeignKey(NewsFeed)
管理员.py:
from django.contrib import admin
from newsfeed.models import NewsFeed,NewsItem
from cms.admin.placeholderadmin import PlaceholderAdmin
class NewsItemInline(admin.StackedInline):
model = NewsItem
extra=0
class NewsFeedAdmin(admin.ModelAdmin):
inlines = [NewsItemInline]
class Media:
js = ('ckeditor/ckeditor/ckeditor.js')
admin.site.register(NewsFeed,NewsFeedAdmin)
来自ckeditor的config.js:
/**
* @license Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.html or http://ckeditor.com/license
*/
CKEDITOR.editorConfig = function( config ) {
// Define changes to default configuration here. For example:
// config.language = 'fr';
// config.uiColor = '#AADC6E';
};