如何安装 django-ckeditor?
在 Stack Overflow 上有两个关于这个编辑器的问题,但没有人回答!
所以我问如何将此 Django 包安装到我的项目中? 我已经按照这些步骤进行操作,没有错误,没有任何错误,但是仍然形式保持不变。为什么??
编辑:继承者模型
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'
)
In Stack Overflow there's two questions about this editor, and nobody answers!!!
So I'm asking how to install this Django package to my project??
I've followed these steps already, have no errors, nothing, and still the form stays the same. Why??
Edit: heres model
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
view:
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,
}))
All form outputed succesfully with {{ form }} tag
settings.py (of the project)
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'
)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
正确显示小部件所需的媒体应存储在表单的
media
对象中。您可以使用{{ form.media }}
在模板中输出所需js的标签。管理员应该自动执行此操作,而在自定义视图中,您必须自己执行此操作...请参阅 表单媒体了解更多信息!The media needed to display the widget correctly should be stored in the form's
media
object. You can output the tag for needed js in your template with{{ form.media }}
. The admin should do this automatically, while in your custom views you have to do it yourself... See the django documentation on form media for more information!好吧,抱歉我是个白痴。在文档中没有任何关于以某种方式手动包含 JS 的文字!所以只要包含它
开发人员是盲目的还是什么?
ok sorry i was an idiot. in documentation there's no words about including JS manually somehow! so just include it
Developers are blind in there or something?