在Stack Overflow中有两个关于this editor的问题,没有人回答!!!
所以我问如何将这个Django软件包安装到我的项目中? 我已经跟着these steps,没有错误,什么都没有,而且表格仍然保持不变。为什么?
编辑:继承人模型
from datetime import datetime
from django.db import models
from django.utils.translation import ugettext_lazy as _, ugettext
from ckeditor.fields import RichTextField
class Newsletter(models.Model):
title = models.CharField(
_(u'Title'),
max_length=200,
help_text=_(u'Newsletter title'),
)
body = RichTextField()
date = models.DateField(
_(u'Date'),
help_text=_(u'Set date when this newsletter should be send')
)
class Meta:
ordering = ['title',]
forms.py
from models import Newsletter, Mail
class NewsletterForm(forms.ModelForm):
class Meta:
model = Newsletter
视图:
from newsletter.models import Newsletter, Mail
from newsletter.forms import NewsletterForm, MailForm
def newsletters_add(request):
form = NewsletterForm()
tpl = "form_newsletter.html"
return render_to_response(tpl, RequestContext(request, {
'form': form,
}))
使用{{form}}标记
成功输出所有表格settings.py(项目的)
CKEDITOR_MEDIA_PREFIX = "/media/ckeditor/"
CKEDITOR_UPLOAD_PATH = "/www/vhosts/sender/media/newsletter/uploads/"
CKEDITOR_UPLOAD_PREFIX = "http://******/media/newsletter/uploads/"
CKEDITOR_RESTRICT_BY_USER = True
CKEDITOR_CONFIGS = {
'default': {
'toolbar': 'Basic',
},
}
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
'django.contrib.admin',
#'tagging',
'debug_toolbar',
'ckeditor',
'mailer',
'newsletter'
)
答案 0 :(得分:6)
正确显示窗口小部件所需的媒体应存储在窗体的media
对象中。您可以使用{{ form.media }}
在模板中输出所需js的标记。管理员应该自动执行此操作,而在您的自定义视图中,您必须自己执行此操作...有关详细信息,请参阅form media上的django文档!
答案 1 :(得分:1)
<script src="http://****/media/ckeditor/ckeditor/ckeditor.js"></script>
开发人员在那里或某事是盲目的?