In a django application, target is to edit e-mail template in a WYSIWYG editor. Using CKEditor works fine, but images can only be included via URL, not via upload.
A similar question is asked here: Django-CKEditor Image Upload
What is not covered there is the case where a Form Field is used, not a Model Field. Also the accepted solution is not really explained.
Current code:
from django import forms
from crispy_forms.helper import FormHelper
class EmailConfirmationTemplateForm(forms.Form):
def __init__(self, *args, **kwargs):
self.email_template = kwargs.pop('email_template')
kwargs.setdefault('initial', {})['email_template'] = self.email_template
super(EmailConfirmationTemplateForm, self).__init__(*args, **kwargs)
self.helper = FormHelper(self)
self.fields['email_template'] = forms.CharField(widget=CKEditorWidget())
Template code:
...
<form>
{% csrf_token %}
{% crispy form %}
</form>
Settings:
INSTALLED_APPS = [
...
'ckeditor',
'ckeditor_uploader',
...
]
CKEDITOR_UPLOAD_PATH = 'cke-uploads/'
CKEDITOR_IMAGE_BACKEND = 'pillow'
Question is: How to have the possibility to upload images in this WYSIWYG editor?
Version Info: django 1.8.16, django-ckeditor 5.2.2