gpt4 book ai didi

django - 如何安装 django-ckeditor?

转载 作者:行者123 更新时间:2023-12-03 05:03:23 25 4
gpt4 key购买 nike

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

表单.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'

)

最佳答案

正确显示小部件所需的媒体应存储在表单的 media 对象中。您可以使用{{ form.media }}在模板中输出所需js的标签。管理员应该自动执行此操作,而在您的自定义 View 中,您必须自己执行此操作...请参阅 django 文档 form media了解更多信息!

关于django - 如何安装 django-ckeditor?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4494912/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com