如何安装django-ckeditor? [英] How do I install django-ckeditor?

查看:129
本文介绍了如何安装django-ckeditor?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Stack Overflow中,有两个关于此编辑器的问题,没有人回答! !

In Stack Overflow there's two questions about this editor, and nobody answers!!!

所以我问如何安装这个Django包到我的项目?
我已遵循这些步骤,没有错误,没有,仍然形式保持不变。为什么??

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??

编辑:heres模式

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}}标记成功输出

All form outputed succesfully with {{ form }} tag

settings.py(项目的)

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'

)


推荐答案

确定抱歉我是一个白痴。在文档中没有关于包括JS手动不知何故!因此只需添加它

ok sorry i was an idiot. in documentation there's no words about including JS manually somehow! so just include it

<script src="http://****/media/ckeditor/ckeditor/ckeditor.js"></script>

开发人员在那里盲目或有什么?

Developers are blind in there or something?

这篇关于如何安装django-ckeditor?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆