'Django | CKEditor - Image Upload option not showing in App
In admin all CKEditor option is showing and working properly. I can upload image in main admin dashboard. But in App in Image "Uoload" option is not showing. Please see those images than you have a clear view,
Others option is working properly without image Upload.
settings.py
THIRD_PARTY_APPS = [
'widget_tweaks',
'ckeditor',
'ckeditor_uploader',
]
INSTALLED_APPS += THIRD_PARTY_APPS + LOCAL_APPS
# CkEditor Upload path
CKEDITOR_UPLOAD_PATH = 'uploads/'
# CkEditor Custom Configuration
CKEDITOR_CONFIGS = {
'default': {
'toolbar': 'Custom',
'width': 680,
'extraPlugins': ','.join(['codesnippet']),
},
}
template.html
<form method="post" enctype="multipart/form-data">{% csrf_token %}>
{{ form.media }}
{{ form.as_p }}
<button type="submit">Submit</button>
</form>
Solution 1:[1]
step1: goto settings.py and add -> X_FRAME_OPTIONS = 'SAMEORIGIN'
step2 goto your forms.py -> here no need to extra widget. step2
Solution 2:[2]
I just had the same problem with version 6.1.0 of django-ckeditor. After thinking about it, look in the github code of the project and apparently there is a new field for the forms that solves this problem, at least for me now if it works well for me.
from django import forms
from ckeditor.fields import RichTextFormField
from ckeditor_uploader.fields import RichTextUploadingFormField
class CkEditorForm(forms.Form):
ckeditor_standard_example = RichTextFormField()
ckeditor_upload_example = RichTextUploadingFormField(
config_name="my-custom-toolbar"
)
Solution 3:[3]
in admin.py :
from django import forms
from django.contrib import admin
from ckeditor_uploader.widgets import CKEditorUploadingWidget
from blog.models import Blog
class BlogAdminForm(forms.ModelForm):
content = forms.CharField(widget=CKEditorUploadingWidget())
class Meta:
model = Blog
fields = '__all__'
class BlogAdmin(admin.ModelAdmin):
form = BlogAdminForm
admin.site.register(Blog, BlogAdmin)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Shohanur Rahman |
Solution 2 | juan aparicio |
Solution 3 | Mr M |