pythondjangoadminsummernote

Django-Summernote editor not showing in Admin


I have a Django app for post-writing. I've integrated django-summernote to the app but I came across a issue that the django summernote widgets is not showing in admin panel. It is working fine and smooth in my template but its not showing in admin panel. Kindly help me out.

settings.py

INSTALLED_APPS += ('django_summernote', ) 
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')
X_FRAME_OPTIONS = 'SAMEORIGIN'

SUMMERNOTE_CONFIG = {
    'iframe': False,
    "jquery": "summernoteJQuery",

    'summernote': {

        'width': '100%'
    }
}

SUMMERNOTE_THEME = 'bs3'

admin.py

from django.contrib import admin
from .models import Post, Comment

from django_summernote.admin import SummernoteModelAdmin


class PostAdmin(SummernoteModelAdmin):
    summernote_fields = ('text',)

admin.site.register(Post,PostAdmin)
admin.site.register(Comment)

urls.py

from django.urls import include
# ...
urlpatterns = [
...
path('summernote/', include('django_summernote.urls')),
...
] 
...
if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL,
                      document_root=settings.MEDIA_ROOT)

screenshotAdminPanel

After 'Iframe = True'


Solution

  • If you are not using Bootstrap or an external CSS framework in your Django admin panel, you have to set 'iframe': True in your SUMMERNOTE_CONFIG. Otherwise, if you are using Bootstrap or an external CSS framework, set it to False. Here's the example:

    # Using SummernoteWidget - iframe mode, default
    'iframe': True,
    
    # Or, you can set it to `False` to use SummernoteInplaceWidget by default - no iframe mode
    # In this case, you have to load Bootstrap/jQuery sources and dependencies manually.
    # Use this when you're already using Bootstrap/jQuery based themes.
    'iframe': False,
    

    Check the documentation for more details: django-summernote GitHub.