Answer the question
In order to leave comments, you need to log in
Which wysiwyg editor to implement in Django 1.8?
Hello to all! I ask for your help. I read a lot of mana on what wysiwyg editor to implement in Django. Most of them are in English, which I don’t understand at all (But these manuals (those in Russian) describe either old versions of the editors and the framework, or even not working solutions at all.
What a wysiwyg with the ability to upload images and clean up the formatting of the copied text put on the site?If it's not hard for you - explain how to do
it.Thanks in advance!
Answer the question
In order to leave comments, you need to log in
Good evening everyone! Finally managed to connect the wysiwyg editor. I want to share for the future with those who have not done this yet :) Maybe someone will come in handy.
So I connected ckeditor like this:
1) Install django-ckeditor with this command: pip install django-ckeditor
2) Add ckeditor to the INSTALLED_APPS list
INSTALLED_APPS = (
................. ,
'ckeditor',
)
import os
, if suddenly you don't have it set, write down the path of the base directoryBASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
, but if you have a value written differently, I advise you not to touch this (existing) line, but simply add another one under it, calling it not BASE_DIR, but in a different way (for example: _PATH). MEDIA_ROOT = os.path.join(BASE_DIR, 'static', 'media')
MEDIA_URL = '/media/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATIC_URL = '/statics/'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'statics'),
)
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)
CKEDITOR_UPLOAD_PATH = "uploads/"
CKEDITOR_IMAGE_BACKEND = "pillow"
CKEDITOR_JQUERY_URL = '//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js'
# CKEDITOR_CONFIGS по сути необязательны. Они влияют на тулбар редактора. Если выключите - будет очень мало инструментов для работы с текстом. После полной настройки - попробуйте с ними поиграться. Возможно найдете для себя какой-то более оптимальный вариант настроек!
CKEDITOR_CONFIGS = {
"default": {
"removePlugins": "stylesheetparser",
'allowedContent': True,
'toolbar_Full': [
['Styles', 'Format', 'Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat' ],
['Image', 'Flash', 'Table', 'HorizontalRule'],
['TextColor', 'BGColor'],
['Smiley','sourcearea', 'SpecialChar'],
[ 'Link', 'Unlink', 'Anchor' ],
[ 'NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote', 'CreateDiv', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', '-', 'BidiLtr', 'BidiRtl', 'Language' ],
[ 'Source', '-', 'Save', 'NewPage', 'Preview', 'Print', '-', 'Templates' ],
[ 'Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo' ],
[ 'Find', 'Replace', '-', 'SelectAll', '-', 'Scayt' ],
[ 'Maximize', 'ShowBlocks' ]
],
}
}
............. ,
url(r'^ckeditor/', include('ckeditor.urls')),
title_story = RichTextField(max_length=255, verbose_name="Название")
anons = RichTextField(max_length=1000, null=True, blank=True, verbose_name="Анонс")
story = RichTextField(verbose_name="Полная статья")
... ну и так далее ....
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question