django-summernote

raw JSON →
0.8.20.0 verified Mon Apr 27 auth: no python

A Django integration for the Summernote WYSIWYG editor. Current version 0.8.20.0. Releases are infrequent; the library is in maintenance mode.

pip install django-summernote
error No module named 'summernote'
cause Missing 'summernote' in INSTALLED_APPS.
fix
Add 'summernote' to INSTALLED_APPS in settings.py.
error 'SummernoteModelAdmin' object has no attribute 'summernote_fields'
cause Forgetting to define summernote_fields attribute, or using a regular ModelAdmin instead of SummernoteModelAdmin.
fix
class PostAdmin(SummernoteModelAdmin): summernote_fields = ('content',)
error IntegrityError: NOT NULL constraint failed: summernote_attachment.uploaded_at
cause Missing migration or incorrect database schema. Likely you didn't run migrations after adding django-summernote.
fix
python manage.py migrate
breaking X-Frame-Options setting is now per-view (since 0.8.19.0). If you previously set X_FRAME_OPTIONS globally to 'SAMEORIGIN', that may still work but the view now sets its own header, which could override your setting. Review your deployment.
fix Ensure your Django X_FRAME_OPTIONS setting is compatible or adjust per-view if needed.
gotcha Do NOT add 'summernote' to INSTALLED_APPS? Actually you MUST add it. It's required for the static files and admin integration.
fix Always include 'summernote' in INSTALLED_APPS.
gotcha The 'summernote_fields' attribute is only for SummernoteModelAdmin. If you use a custom form, you must manually set the widget to SummernoteWidget.
fix Use summernote_fields = ('field1', 'field2') in the admin class that extends SummernoteModelAdmin.
deprecated Old import paths like 'from summernote import SummernoteWidget' are deprecated. Always import from the correct module.
fix Use 'from summernote.widgets import SummernoteWidget'

Basic admin integration with Summernote for a Post model with a content field.

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'summernote',
]

# settings.py
SUMMERNOTE_CONFIG = {
    'summernote': {
        'width': '100%',
        'height': '480',
    },
}

# admin.py
from django.contrib import admin
from summernote.admin import SummernoteModelAdmin
from .models import Post

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

admin.site.register(Post, PostAdmin)