0

Django: Installing Django Ckeditor, Ckeditor is awesome editor and most popular editor was used for website, and compatible with django.

1. Install or add django-ckeditor to your python path.

$ pip install django-ckeditor

2. Add ckeditor and ckeditor_uploader to your INSTALLED_APPS setting.

3. django-ckeditor uses jQuery in ckeditor-init.js file. You must set CKEDITOR_JQUERY_URL to a jQuery URL that will be used to load the library. If you have jQuery loaded from a different source just don’t set [CKEDITOR_JQUERY_URL] and django-ckeditor will not try to load its own jQuery. If you find that CKEditor widgets don’t appear in your Django admin site then check that this variable is set correctly. Example:

CKEDITOR_JQUERY_URL = '//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js'

4. 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.

For more installation you can checkout on this repository: https://github.com/django-ckeditor/django-ckeditor#installation

And in this post we want to show you how to setting `Choose File` for your image like this picture:

Django Ckeditor Upload Image

Default setting from ckeditor uses RichTextField, so like what was notice says: “Django admin CKEditor integration. Provides a RichTextField, RichTextUploadingField, CKEditorWidget and CKEditorUploadingWidget utilizing CKEditor with image upload and browsing support included.”

in your models.py change RichTextField() to RichTextUploadingField()

from ckeditor_uploader.fields import RichTextUploadingField

class Entry(models.Model):
    title = models.CharField(max_length=200)
    slug = models.SlugField(max_length=200, unique=True)
    images = models.ImageField(upload_to='blog/images/%Y/%m/%d', blank=True)
    tags = models.ManyToManyField('Tag')
    body = RichTextUploadingField() #RichTextField()

Helpfull can help.
Thanks for Lukman Namkul for solved this problem.

app python django

Your Answer

blog comments powered by Disqus