简体   繁体   中英

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'

if you are using not using BootStrap or external CSS framework in your Django admin panel than you have to set 'iframe': True, other wise you have to set it to False check this doc. https://github.com/summernote/django-summernote

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,

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM