Code Monkey home page Code Monkey logo

django-ckeditor's Introduction

I do not recommend using this package anymore since the open source version of CKEditor 4 has unfixed security issues. More on this in my blog post. Alternatives are listed here on Django Packages. I personally am using django-prose-editor. Thanks!

https://readthedocs.org/projects/django-ckeditor/badge/?version=latest&style=flat

Django admin CKEditor integration.

Provides a RichTextField, RichTextUploadingField, CKEditorWidget and CKEditorUploadingWidget utilizing CKEditor with image uploading and browsing support included.

This version also includes:

  1. support to django-storages (works with S3)
  2. updated ckeditor to version 4.18.0
  3. included all ckeditor language and plugin files to make everyone happy! ( only the plugins maintained by the ckeditor develops team )
  1. Install or add django-ckeditor to your python path.

    pip install django-ckeditor
    
  2. Add ckeditor to your INSTALLED_APPS setting.

  3. Run the collectstatic management command: $ ./manage.py collectstatic. This will copy static CKEditor required media resources into the directory given by the STATIC_ROOT setting. See Django's documentation on managing static files for more info.

  4. CKEditor needs to know where its assets are located because it loads them lazily only when needed. The location is determined in the ckeditor-init.js script. and defaults to static/ckeditor/ckeditor/. This does not work all the time, for example when using ManifestStaticFilesStorage, any asset packaging pipeline or whatnot. django-ckeditor is quite good at automatically detecting the correct place even then, but sometimes you have to hardcode CKEDITOR_BASEPATH somewhere. This can be hardcoded in settings, i.e.:

    CKEDITOR_BASEPATH = "/my_static/ckeditor/ckeditor/"
    

    It is possible to override the admin/change_form.html template with your own if you really need to do this, i.e.:

    {% extends "admin/change_form.html" %}
    
    {% block extrahead %}
    <script>window.CKEDITOR_BASEPATH = '/my_static/ckeditor/ckeditor/';</script>
    {{ block.super }}
    {% endblock %}
    

    Of course, you should adapt this snippet to your needs when using CKEditor outside the admin app.

  1. Add ckeditor_uploader to your INSTALLED_APPS setting.

  2. Add a CKEDITOR_UPLOAD_PATH setting to the project's settings.py file. This setting specifies a relative path to your CKEditor media upload directory. CKEditor uses Django's storage API. By default, Django uses the file system storage backend (it will use your MEDIA_ROOT and MEDIA_URL) and if you don't use a different backend you have to have write permissions for the CKEDITOR_UPLOAD_PATH path within MEDIA_ROOT, i.e.:

    CKEDITOR_UPLOAD_PATH = "uploads/"
    

    When using default file system storage, images will be uploaded to "uploads" folder in your MEDIA_ROOT and urls will be created against MEDIA_URL (/media/uploads/image.jpg).

    If you want to be able to have control over filename generation, you have to add a custom filename generator to your settings:

    # utils.py
    
    def get_filename(filename, request):
        return filename.upper()
    
    # settings.py
    
    CKEDITOR_FILENAME_GENERATOR = 'utils.get_filename'
    

    CKEditor has been tested with django FileSystemStorage and S3BotoStorage. There are issues using S3Storage from django-storages.

  3. For the default filesystem storage configuration, MEDIA_ROOT and MEDIA_URL must be set correctly for the media files to work (like those uploaded by the ckeditor widget).

  4. Add CKEditor URL include to your project's urls.py file:

    path('ckeditor/', include('ckeditor_uploader.urls')),
    
  5. Note that by adding those URLs you add views that can upload and browse through uploaded images. Since django-ckeditor 4.4.6, those views are decorated using @staff_member_required. If you want a different permission decorator (login_required, user_passes_test etc.) then add views defined in ckeditor.urls manually to your urls.py.

  1. Add a CKEDITOR_CONFIGS setting to the project's settings.py file. This specifies sets of CKEditor settings that are passed to CKEditor (see CKEditor's Setting Configurations), i.e.:

    CKEDITOR_CONFIGS = {
        'awesome_ckeditor': {
            'toolbar': 'Basic',
        },
    }
    

    The name of the settings can be referenced when instantiating a RichTextField:

    content = RichTextField(config_name='awesome_ckeditor')
    

    The name of the settings can be referenced when instantiating a CKEditorWidget:

    widget = CKEditorWidget(config_name='awesome_ckeditor')
    

    By specifying a set named default you'll be applying its settings to all RichTextField and CKEditorWidget objects for which config_name has not been explicitly defined

    CKEDITOR_CONFIGS = {
        'default': {
            'toolbar': 'full',
            'height': 300,
            'width': 300,
        },
    }
    

    It is possible to create a custom toolbar

    CKEDITOR_CONFIGS = {
        'default': {
            'toolbar': 'Custom',
            'toolbar_Custom': [
                ['Bold', 'Italic', 'Underline'],
                ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'],
                ['Link', 'Unlink'],
                ['RemoveFormat', 'Source']
            ]
        }
    }
    

    If you want or need plugins which are not part of django-ckeditor's plugin set you may specify assets and plugins as follows:

        text = RichTextField(
            config_name='forum-post',
    
            # CKEDITOR.config.extraPlugins:
            extra_plugins=['someplugin'],
    
            # CKEDITOR.plugins.addExternal(...)
            external_plugin_resources=[(
                'someplugin',
                '/static/.../path-to-someplugin/',
                'plugin.js',
            )],
        )
    
    Alternatively, those settings can also be provided through
    ``CKEDITOR_CONFIGS``.
    
  1. All uploaded files are slugified by default. To disable this feature, set CKEDITOR_UPLOAD_SLUGIFY_FILENAME to False.

  2. Set the CKEDITOR_RESTRICT_BY_USER setting to True in the project's settings.py file (default False). This restricts access to uploaded images to the uploading user (e.g. each user only sees and uploads their own images). Upload paths are prefixed by the string returned by get_username. If CKEDITOR_RESTRICT_BY_USER is set to a string, the named property is used instead. Superusers can still see all images. NOTE: This restriction is only enforced within the CKEditor media browser.

  3. Set the CKEDITOR_BROWSE_SHOW_DIRS setting to True to show directories on the "Browse Server" page. This enables image grouping by directory they are stored in, sorted by date.

  4. Set the CKEDITOR_RESTRICT_BY_DATE setting to True to bucked uploaded files by year/month/day.

  5. You can set a custom file storage for CKEditor uploader by defining it under CKEDITOR_STORAGE_BACKEND variable in settings.

  6. You can set CKEDITOR_IMAGE_BACKEND to one of the supported backends to enable thumbnails in ckeditor gallery. By default, no thumbnails are created and full-size images are used as preview. Supported backends:

    • ckeditor_uploader.backends.PillowBackend: Uses Pillow
  7. With the PillowBackend backend, you can change the thumbnail size with the CKEDITOR_THUMBNAIL_SIZE setting (formerly THUMBNAIL_SIZE). Default value: (75, 75)

  8. With the PillowBackend backend, you can convert and compress the uploaded images to jpeg, to save disk space. Set the CKEDITOR_FORCE_JPEG_COMPRESSION setting to True (default False) You can change the CKEDITOR_IMAGE_QUALITY setting (formerly IMAGE_QUALITY), which is passed to Pillow:

    The image quality, on a scale from 1 (worst) to 95 (best). The default is 75. Values above 95 should be avoided; 100 disables portions of the JPEG compression algorithm and results in large files with hardly any gain in image quality.

    This feature is disabled for animated images.

The quickest way to add rich text editing capabilities to your models is to use the included RichTextField model field type. A CKEditor widget is rendered as the form field but in all other regards the field behaves like the standard Django TextField. For example:

from django.db import models
from ckeditor.fields import RichTextField

class Post(models.Model):
    content = RichTextField()

For file upload support use RichTextUploadingField from ckeditor_uploader.fields.

Alternatively, you can use the included CKEditorWidget as the widget for a formfield. For example:

from django import forms
from django.contrib import admin
from ckeditor.widgets import CKEditorWidget

from post.models import Post

class PostAdminForm(forms.ModelForm):
    content = forms.CharField(widget=CKEditorWidget())
    class Meta:
        model = Post
        fields = '__all__'

class PostAdmin(admin.ModelAdmin):
    form = PostAdminForm

admin.site.register(Post, PostAdmin)

For file upload support use CKEditorUploadingWidget from ckeditor_uploader.widgets.

Overriding widget template

In Django >=1.11 for overriding ckeditor/widget.html you have three ways:

  1. Place ckeditor/widget.html in BASE_DIR/templates

    • Change FORM_RENDERER to TemplateSettings.
    FORM_RENDERER = 'django.forms.renderers.TemplatesSetting'
    
    • Include templates folder in DIRS
    TEMPLATES = [{
        ...
        'DIRS': [os.path.join(BASE_DIR, 'templates'), ],
        ...
    }]
    
    • Add 'django.forms' to INSTALLED_APPS.
  2. Place ckeditor/widget.html in your_app/templates and place 'your_app' before 'ckeditor' and 'ckeditor_uploader' in INSTALLED_APPS.

  3. Inherit from CKEditorWidget and override template_name with a custom template available in TEMPLATES DIRS as defined settings.py.

    class MyCustomCKEditorWidget(CKEditorWidget):
       template_name = "templates/custom_ckeditor/widget.html"
    

When you are rendering a form outside the admin panel, you'll have to make sure all form media is present for the editor to work. One way to achieve this is like this:

<form>
    {{ myform.media }}
    {{ myform.as_p }}
    <input type="submit"/>
</form>

or you can load the media manually as it is done in the demo app:

{% load static %}
<script type="text/javascript" src="{% static "ckeditor/ckeditor-init.js" %}"></script>
<script type="text/javascript" src="{% static "ckeditor/ckeditor/ckeditor.js" %}"></script>

When you need to render RichTextField's HTML output in your templates safely, just use {{ content|safe }}, Django's safe filter

Included is a management command to create thumbnails for images already contained in CKEDITOR_UPLOAD_PATH. This is useful to create thumbnails when using django-ckeditor with existing images. Issue the command as follows:

$ ./manage.py generateckeditorthumbnails

NOTE: If you're using custom views remember to include ckeditor.js in your form's media either through {{ form.media }} or through a <script> tag. Admin will do this for you automatically. See Django's Form Media docs for more info.

See https://django-storages.readthedocs.org/en/latest/

NOTE: django-ckeditor will not work with S3 through django-storages without this line in settings.py:

AWS_QUERYSTRING_AUTH = False

To get allowedContent to work, disable stylesheetparser plugin. So include this in your settings.py.:

CKEDITOR_CONFIGS = {
    "default": {
        "removePlugins": "stylesheetparser",
    }
}

django-ckeditor includes the following ckeditor plugins, but not all are enabled by default:

a11yhelp, about, adobeair, ajax, autoembed, autogrow, autolink, bbcode, clipboard, codesnippet,
codesnippetgeshi, colordialog, devtools, dialog, div, divarea, docprops, embed, embedbase,
embedsemantic, filetools, find, flash, forms, iframe, iframedialog, image, image2, language,
lineutils, link, liststyle, magicline, mathjax, menubutton, notification, notificationaggregator,
pagebreak, pastefromword, placeholder, preview, scayt, sharedspace, showblocks, smiley,
sourcedialog, specialchar, stylesheetparser, table, tableresize, tabletools, templates, uicolor,
uploadimage, uploadwidget, widget, wsc, xml

The image/file upload feature is done by the uploadimage plugin.

  1. To restrict upload functionality to image files only, add CKEDITOR_ALLOW_NONIMAGE_FILES = False in your settings.py file. Currently non-image files are allowed by default.
  2. By default the upload and browse URLs use staff_member_required decorator - ckeditor_uploader/urls.py - if you want other decorators just insert two urls found in that urls.py and don't include it.

If you clone the repository you will be able to run the ckeditor_demo application.

  1. pip install -r ckeditor_demo_requirements.txt
  2. Run python manage.py migrate
  3. Create a superuser if you want to test the widget in the admin panel
  4. Start the development server.

There is a forms.Form on the main page (/) and a model in admin that uses the widget for a model field. Database is set to sqlite3 and STATIC/MEDIA_ROOT to folders in temporary directory.

The recommended way to run selenium tests is using tox. Select the appropriate selenium driver using the SELENIUM environment variable and optionally specify that you want to run only one environment since selenium takes some time and/or since you do not have all supported versions of Python installed locally. The example uses the combination of Python 3.9 and Django 4.0 which is a supported combination at the time of writing:

# Either
SELENIUM=firefox tox -e py39-dj40

# Or
SELENIUM=chromium tox -e py39-dj40

# Or even
SELENIUM=firefox tox

If your browser has problems displaying uploaded images in the image upload window you may need to change Django settings:

X_FRAME_OPTIONS = 'SAMEORIGIN'

More on https://docs.djangoproject.com/en/1.11/ref/clickjacking/#setting-x-frame-options-for-all-responses

CKEDITOR_CONFIGS = {
    'default': {
        'skin': 'moono',
        # 'skin': 'office2013',
        'toolbar_Basic': [
            ['Source', '-', 'Bold', 'Italic']
        ],
        'toolbar_YourCustomToolbarConfig': [
            {'name': 'document', 'items': ['Source', '-', 'Save', 'NewPage', 'Preview', 'Print', '-', 'Templates']},
            {'name': 'clipboard', 'items': ['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo']},
            {'name': 'editing', 'items': ['Find', 'Replace', '-', 'SelectAll']},
            {'name': 'forms',
             'items': ['Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton',
                       'HiddenField']},
            '/',
            {'name': 'basicstyles',
             'items': ['Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat']},
            {'name': 'paragraph',
             'items': ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote', 'CreateDiv', '-',
                       'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', '-', 'BidiLtr', 'BidiRtl',
                       'Language']},
            {'name': 'links', 'items': ['Link', 'Unlink', 'Anchor']},
            {'name': 'insert',
             'items': ['Image', 'Flash', 'Table', 'HorizontalRule', 'Smiley', 'SpecialChar', 'PageBreak', 'Iframe']},
            '/',
            {'name': 'styles', 'items': ['Styles', 'Format', 'Font', 'FontSize']},
            {'name': 'colors', 'items': ['TextColor', 'BGColor']},
            {'name': 'tools', 'items': ['Maximize', 'ShowBlocks']},
            {'name': 'about', 'items': ['About']},
            '/',  # put this to force next toolbar on new line
            {'name': 'yourcustomtools', 'items': [
                # put the name of your editor.ui.addButton here
                'Preview',
                'Maximize',

            ]},
        ],
        'toolbar': 'YourCustomToolbarConfig',  # put selected toolbar config here
        # 'toolbarGroups': [{ 'name': 'document', 'groups': [ 'mode', 'document', 'doctools' ] }],
        # 'height': 291,
        # 'width': '100%',
        # 'filebrowserWindowHeight': 725,
        # 'filebrowserWindowWidth': 940,
        # 'toolbarCanCollapse': True,
        # 'mathJaxLib': '//cdn.mathjax.org/mathjax/2.2-latest/MathJax.js?config=TeX-AMS_HTML',
        'tabSpaces': 4,
        'extraPlugins': ','.join([
            'uploadimage', # the upload image feature
            # your extra plugins here
            'div',
            'autolink',
            'autoembed',
            'embedsemantic',
            'autogrow',
            # 'devtools',
            'widget',
            'lineutils',
            'clipboard',
            'dialog',
            'dialogui',
            'elementspath'
        ]),
    }
}

django-ckeditor's People

Contributors

2lopez avatar 3point2 avatar ahumeau avatar aliymn avatar b2550 avatar bschuon avatar christianglodt avatar ddabble avatar dekoza avatar dessibelle avatar dustingtorres avatar flimm avatar horejsek avatar hsmett avatar luzfcb avatar machinist avatar matthiask avatar mauler avatar nikolas avatar radiovisual avatar rgcarrasqueira avatar riklaunim avatar rokj avatar simonpanay avatar sylvain-josserand avatar tomwys avatar visgean avatar vparitskiy avatar vstoykov avatar zefj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-ckeditor's Issues

Use ckeditor with feincms or simple inline

Hello!

Sorry for my English.

I'm use feincms (https://github.com/feincms/feincms/) and django-ckeditor with file upload support (https://github.com/shaunsephton/django-ckeditor).

I create a feincms content type for RichTextField:

class RichContent(models.Model):
    text = RichTextField(_('text'))

    class Meta:
        abstract = True
        verbose_name = _('Rich Text')
        verbose_name_plural =_('Rich Text')

    def render(self, **kwargs):
        context_instance = kwargs.get('context_instance')

        return render_to_string('content/page/rich_content.html', {
            'page': self,
        }, context_instance=context_instance)

But in django admin, when i select 'Rich Text' and press 'Go', get this error in firebug console:

uncaught exception: [CKEDITOR.editor] The instance "id_richcontent_set-__prefix__-text" already exists.

And textarea in ckeditor do not editable.

How i can use normal ckeditor (no simple textarea) with inline?

Thanks!

Pillow instead of PIL?

I've recently moved to Pillow since it's more frequently updated and I use this in all my buildout configs. django-ckeditor uses PIL in it's requirements, and this then gets installed into my buildout as well.

What would be the possibility to move to Pillow? If none, is there a way to force buildout not to use the PIL dependency?

Problem with special characters in uploaded filename

Hi, If I am trying to upload a file with name for example čaj.jpg I get this:

MultiValueDictKeyError at /ckeditor/upload/

"Key 'upload' not found in <MultiValueDict: {}>"

Request Method: GET
Request URL: http://localhost:8000/ckeditor/upload/?CKEditor=id_text&CKEditorFuncNum=2&langCode=cs
Django Version: 1.4.1
Exception Type: MultiValueDictKeyError
Exception Value:

"Key 'upload' not found in <MultiValueDict: {}>"

Exception Location: /home/milos/.virtualenvs/mawen/local/lib/python2.7/site-packages/django/utils/datastructures.py in getitem, line 258
Python Executable: /home/milos/.virtualenvs/mawen/bin/python
Python Version: 2.7.3

I was trying to verify if everything about form encoding is fine, but I could not find proper templates..

Tabs in twitter bootstrap

ckeditor 4.x version not working in all browsers when using the library of twitter bootstrap tabs.

CSRF token

I installed ckeditor to allow Rich Text editor with image upload in my models. The problem is that when I try to upload an image to the server, it shows me a Forbidden error stating that there's no CSRF token passed.

How can I upload an image to the server?

Thanks

Not always picking up PIL

I haven't figured out what PIL is doing, but some of my servers have it installed as
from PIL import Image
while others are just
import Image

django-ckeditor expects only the former syntax. This can be fixed using the folliwing patch:

diff --git a/ckeditor/views.py b/ckeditor/views.py
index 66e1e6e..0091cf5 100644
--- a/ckeditor/views.py
+++ b/ckeditor/views.py
@@ -6,7 +6,10 @@ from django.shortcuts import render_to_response
from django.template import RequestContext
from django.views.decorators.csrf import csrf_exempt

-from PIL import Image, ImageOps
+try:

  • from PIL import Image, ImageOps
    +except ImportError:
  • import Image, ImageOps

THUMBNAIL_SIZE = (75, 75)

Require login for file browser

/ckeditor/browse should be visible only to logged in staff members.
A good way would be to specify this in the settings file and have the restriction set to True by default.
CKEDITOR_REQUIRE_STAFF=True

Loading file in images section that is not an image.

Hello,

When I try to upload a file using CKEDITOR tool but it is not an image generate an error. It is probably a CKEDITOR bug. I was checking the code and there are a part of code where there is not a try - except.

This is the error:

File "/home/cloudbcn/.virtualenvs/cloudbcn/local/lib/python2.7/site-packages/ckeditor/views.py", line 54, in create_thumbnail
image = Image.open(filename)
File "/home/cloudbcn/.virtualenvs/cloudbcn/local/lib/python2.7/site-packages/PIL/Image.py", line 2008, in open
raise IOError("cannot identify image file")
IOError: cannot identify image file

This is the part of code where the error is thrown:

def create_thumbnail(filename):
    image = Image.open(filename)

    # Convert to RGB if necessary
    # Thanks to Limodou on DjangoSnippets.org
    # http://www.djangosnippets.org/snippets/20/
    if image.mode not in ('L', 'RGB'):
        image = image.convert('RGB')

    # scale and crop to thumbnail
    imagefit = ImageOps.fit(image, THUMBNAIL_SIZE, Image.ANTIALIAS)
    imagefit.save(get_thumb_filename(filename))

When try to instance Image to generate the thumbnail, generate an exception, because is not an image, example a PDF o CSV.

image = Image.open(filename)

I posted this issue in stackoverflow, link access:
http://stackoverflow.com/questions/19125287/problems-loading-file-in-ckeditor-django

I am using:

  • django 1.5.1
  • django-ckeditor 4.0.2

Thanks for your answers.

django-ckeditor image upload giving wrong url of the image

When I try text editing and other text related stuffs and save it, the editor does its job nicely. But when I try to upload an image it just take a different url. I am on windows. Is it because of this, cause I saw a post, but it didn't helped me either. It does get saved and they each have their own thumbnails too. But its just that the wrong urls.
I checked the src of the image, and it was like this,

<img alt="" src="/media/3/10/17Hydrangeas.jpg" />

But it should have been like this,

<img alt="" src="/media/2013/10/17/Hydrangeas.jpg" />

And sometimes the src of the image is just like this,

<img alt="" src="/media/3/10/17" />

This is the snippet of my settings.py:

CKEDITOR_UPLOAD_PATH = 'C:/Users/Nanyoo/web/demo/media'
MEDIA_ROOT = 'C:/Users/Nanyoo/web/demo/media'

I've included its url in my urls.py:

(r'^ckeditor/', include('ckeditor.urls')),

models.py:

from django.db import models
from datetime import datetime
from django.contrib.auth.models import User
from time import time


def get_upload_file_name(instance, filename):
    return "uploaded_files/%s_%s" %(str(time()).replace('.','_'), filename)

class Blog(models.Model):
    title = models.CharField(max_length=200)
    image = models.ImageField(upload_to=get_upload_file_name, blank=True)
    pub_date = models.DateTimeField(default=datetime.now)
    creator = models.ForeignKey(User, related_name="creator_set")
    body = models.TextField()

In the forms.py:

from django import forms
from django_summernote.widgets import SummernoteWidget
from ckeditor.widgets import CKEditorWidget

class BlogForm(forms.Form):
    title = forms.CharField(max_length=200,widget=SummernoteWidget())
    body = forms.CharField(widget=CKEditorWidget())

In the index.html:

        {% for blog in blogs %}
        <div id="page">
                <h1>{{ blog.title | safe}}</h1>
                <p>{{ blog.body | safe}}</p>
        </div>
        {% endfor %}

my form in the html:

{% block content %} 
    <form method="post" action=".">
    {% csrf_token %}
    <fieldset id="create_blog">
        {{form.media}}
        {{ form.as_p}}
        <input type="submit" value="Post Blog" />
    </fieldset>
    </form>
{% endblock %}

Please help me figure it out. Any help will be greatly appreciated!

Thanks!

Apply Custom style in ckeditor

Hello,

I want to add custom style for ckeditor for some specific application field.
There will any way to add whole html file start from to in filed which override ckeditor . When i do this then source sode is not display. Source only display only when i add the body content in that field.

Thanks

Make image upload optional

Requiring PIL/Pillow for a WYSIWYG editior widget is overkill. Seems to me that the whole uploading/thumbnailing feature should be optional.

Adding inline RichTextField doesn't work

Use a RichTextField in an inline model. Try to add an instance. You get

uncaught exception: [CKEDITOR.editor] The instance "id_answer_set-prefix-answer" already exists

This makes it impossible to use the newly created CKEditor field. Looking through the code (I have no idea how CKEditor works, just guessing) it generates a td with id="cke_contents_id_answer_set-prefix-answer" on an added inline, my RichTextField is called "answer". The invisible textfield's id is "id_answer_set-1-answer" Notice the 1 which identifies it. I would assume the td's id should thus be "cke_contents_id_answer_set-1__prefix__-answer"

There is a related stackoverflow question asked back in February with no answer.
http://stackoverflow.com/questions/5137478/django-ckeditor-uncaught-exception-using-inlines

Windows Paths Not Corrected for Image Uploads

After uploading images, the paths generated by get_media_url(path) don't replace the Windows environment separator ('\') with the needed '/' character. This leads to broken links in the embed views.

I replaced the "url.replace()" line of that function with the following to add Windows support:

return url.replace('//', '/').replace('\\', '/')

settings.CKEDITOR_CONFIGS seems to be ignored

Firstly, thanks for your great library!

I have three different widgets and would like to use a different toolbar for each. I have specified config_name in the widget constructor and the settings are not applied. all of widgets seem to use the same config_name.

I have worked around this by overriding render and setting my config in there but I thought I would let you know.

Make loading of jquery optional

Widget is overloading jQuery which leads to confusion and errors, please add support in settings to disable loading jQuery if a newer version is already loaded manually

ckeditor does not create thumbs for uploaded images

here's error:
TypeError at /ckeditor/upload/
function takes at most 4 arguments (6 given)

out = open(upload_filename, 'wb+')
for chunk in upload.chunks():
    out.write(chunk)
out.close()
**create_thumbnail(upload_filename) ...**
url = get_media_url(upload_filename)
return HttpResponse("""
<script type='text/javascript'>
    window.parent.CKEDITOR.tools.callFunction(%s, '%s');...

Upgrade CKEDITOR to 4.1.x

Helo @shaunsephton.

CKEDITOR 4.1.x is the last version so far, and by ckeditor changelog http://ckeditor.com/whatsnew there is no much changes that can impact.

Myself did a drop in replacement from ckeditor 4.0.2 to 4.1 at https://github.com/chronossc/django-ckeditor/tree/ckeditor_update and so far is working well.

Also, we don't know how upgrade ckeditor in djang-ckeditor app, would be nice to document it, if we should change something more than static/ckeditor/ckeditor.

Thx

Is collectstatic really needed?

I've just setup django-ckeditor and I'm not sure if running collectstatic is really necessary or mandatory. I ran it and, as expected, a lot of directories were copied into STATIC_ROOT. I deleted all except ckeditor. I tested it and it worked, then I removed the ckeditor directory and it still works. In the server log I can see the 200 status code for the ckeditor gets in the development server. Is it necessary in production or can I completely remove this directory?

Additional Info

Hi Shaunsephton,

In django 1.6 url modules are found in "django.conf.urls". But in ckeditor urls, urls are imported from "django.conf.urls.defaults". This has to be editted to that of django 1.6

Also we need to include ckeditor.js file in our django template to render ckeditor interface correctly.

Which version to download?

Hi
Which version do i download for non image files upload skill with recent upload skills ? Master download do not have those skills?

And is there a way to delete files in file browser?

Thank you very much

Modify installation order in README

Installation steps 3 and 4 should be switched in the README. Otherwise an exception will be thrown after running collectstatic:

django.core.exceptions.ImproperlyConfigured: django-ckeditor requires CKEDITOR_UPLOAD_PATH setting. This setting specifies an absolute path to your ckeditor media upload directory. Make sure you have write permissions for the path, i.e.: CKEDITOR_UPLOAD_PATH = '/home/media/media.lawrence.com/uploads'

X-Frame-Options on upload view

I am using Django 1.3 and was having problems making the upload view work. The upload occurred without problems but the url never reached the dialog. After adding response['X-Frame-Options'] = 'SAMEORIGIN' to the uploads view it worked. Have you seen this behavior before on django-ckeditor?

Thanks,
Zuzel

Conflict with the classes: collapse in admin

class ExhibitionAdmin(CommonAdmin):
    fieldsets = [
        (None,               {'fields': ['title', 'shorttitle']}),
        (None,               {'fields': ['parent', 'content', 'logo', 'logo_alt', 'link', 'period', 'begin_date', 'end_date', 'worktime', 'visit_conditions', 'full_name', 'expocenter', 'place', 'place_link', 'organizer_1', 'organizer_2', 'product_group', 'description_on_home']}),
        (u'Классификаторы',  {'fields': ['subjects', 'activities', 'sectors', 'products'], 'classes': ['collapse']}),
        (u'Отображение',     {'fields': ['status', 'sort_order', 'slug']}),
        (u'SEO',             {'fields': ['pagetitle', 'keywords', 'description', 'priority'], 'classes': ['collapse']}),
        (u'Служебное',       {'fields': ['notes'], 'classes': ['collapse']}),
    ]

    def formfield_for_dbfield(self, db_field, **kwargs):
        #if db_field.name == 'content':
        #    kwargs['widget'] = CKEditorWidget()
        #if db_field.name == 'description_on_home':
        #    kwargs['widget'] = CKEditorWidget(config_name='description')
        return super(ExhibitionAdmin,self).formfield_for_dbfield(db_field,**kwargs)

'classes': ['collapse'] works only if I comment out kwargs['widget'] = CKEditorWidget() lines...

Decouple Storage

Utilize Django's storage system to allow for wider range of upload storage options, i.e. Amazon S3.

Need help maintaining?

There's a lot of pull requests here. I'd be happy to help review and merge them if you want. I'm sure a lot of people are going to want 1.6 support when it's released soon. You can review my work at github.com/burke-software/

Editor is collapsed when it is in a collapsed class.

When CKEDITOR instance is placed into collapsed class, the height of the editor is 23px. Тhe user has to expand the size of the editor manually, because the text area is not visible. Is this a bug of it is a feature?

install error on ubuntu 12.04

./setup.py: 1: ./setup.py: import: not found
from: can't read /var/mail/setuptools
./setup.py: 5: ./setup.py: Syntax error: "(" unexpected

Incorrect image path in the css

Image path background-image: url('images/loader.gif'); is incorrect path in the file ckeditor/static/ckeditor/galleriffic/css/galleriffic-5.css line 58. "images/" directory should be wiped out as there is none.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.