Simply integrate Summernote editor with Django project.

Overview

django-summernote

Build Status Coverage Status

Summernote is a simple WYSIWYG editor.

django-summernote allows you to embed Summernote into Django very handy. Support admin mixins and widgets.

django-summernote

SETUP

  1. Install django-summernote to your python environment.

    pip install django-summernote
    
  2. Add django_summernote to INSTALLED_APPS in settings.py.

    INSTALLED_APPS += ('django_summernote', )
    
  3. Add django_summernote.urls to urls.py.

    • For Django 1.x

      urlpatterns = [
          ...
          url(r'^summernote/', include('django_summernote.urls')),
          ...
      ]
      
    • For Django 2.x

      from django.urls import include
      # ...
      urlpatterns = [
          ...
          path('summernote/', include('django_summernote.urls')),
          ...
      ]
      
  4. Be sure to set proper MEDIA_URL for attachments.

    • The following is an example test code:

      MEDIA_URL = '/media/'
      MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')
      
    • When debug option is enabled(DEBUG=True), DO NOT forget to add urlpatterns as shown below:

      from django.conf import settings
      from django.conf.urls.static import static
      
      if settings.DEBUG:
          urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
      
    • Please, read the official v3.0 documentation for more details on file uploads.

  5. Run database migration for preparing attachment model.

    python manage.py migrate
    

USAGE

Django admin site

Apply summernote to all TextField in model

In admin.py,

from django_summernote.admin import SummernoteModelAdmin
from .models import SomeModel

# Apply summernote to all TextField in model.
class SomeModelAdmin(SummernoteModelAdmin):  # instead of ModelAdmin
    summernote_fields = '__all__'

admin.site.register(SomeModel, SomeModelAdmin)

Apply summernote only to specific TextField in model

Although Post model has several TextField, only content field will have SummernoteWidget.

In admin.py,

from django_summernote.admin import SummernoteModelAdmin
from .models import Post

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

admin.site.register(Post, PostAdmin)

Form

In forms,

from django_summernote.widgets import SummernoteWidget, SummernoteInplaceWidget

# Apply summernote to specific fields.
class SomeForm(forms.Form):
    foo = forms.CharField(widget=SummernoteWidget())  # instead of forms.Textarea

# If you don't like <iframe>, then use inplace widget
# Or if you're using django-crispy-forms, please use this.
class AnotherForm(forms.Form):
    bar = forms.CharField(widget=SummernoteInplaceWidget())

And for ModelForm,

class FormFromSomeModel(forms.ModelForm):
    class Meta:
        model = SomeModel
        widgets = {
            'foo': SummernoteWidget(),
            'bar': SummernoteInplaceWidget(),
        }

Last, please don't forget to use safe templatetag while displaying in templates.

{{ foobar|safe }}

Warning: Please mind, that the widget does not provide any escaping. If you expose the widget to external users without taking care of this, it could potentially lead to an injection vulnerability. Therefore you can use the SummernoteTextFormField or SummernoteTextField, which escape all harmful tags through mozilla's package bleach:

In forms,

from django_summernote.fields import SummernoteTextFormField, SummernoteTextField

class SomeForm(forms.Form):
    foo = SummernoteTextFormField()

And for ModelForm,

class FormForSomeModel(forms.ModelForm):
    foo = SummernoteTextField()

THEMES

django-summernote is served with Bootstrap3 by default, but you can choose other options. You can change the theme by setting SUMMERNOTE_THEME = '<theme_name>' in settings.py.

SUMMERNOTE_THEME accepts the following values:

  • bs3: Bootstrap3 theme
  • bs4: Bootstrap4 theme
  • lite: Lite UI theme (without Bootstrap)

In settings.py

SUMMERNOTE_THEME = 'bs4'  # Show summernote with Bootstrap4

OPTIONS

Support customization via settings. Put SUMMERNOTE_CONFIG into your settings file.

In settings.py,

SUMMERNOTE_CONFIG = {
    # 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,

    # You can put custom Summernote settings
    'summernote': {
        # As an example, using Summernote Air-mode
        'airMode': False,

        # Change editor size
        'width': '100%',
        'height': '480',

        # Use proper language setting automatically (default)
        'lang': None,

        # Toolbar customization
        # https://summernote.org/deep-dive/#custom-toolbar-popover
        'toolbar': [
            ['style', ['style']],
            ['font', ['bold', 'underline', 'clear']],
            ['fontname', ['fontname']],
            ['color', ['color']],
            ['para', ['ul', 'ol', 'paragraph']],
            ['table', ['table']],
            ['insert', ['link', 'picture', 'video']],
            ['view', ['fullscreen', 'codeview', 'help']],
        ],

        # Or, explicitly set language/locale for editor
        'lang': 'ko-KR',
        ...

        # You can also add custom settings for external plugins
        'print': {
            'stylesheetUrl': '/some_static_folder/printable.css',
        },
        'codemirror': {
            'mode': 'htmlmixed',
            'lineNumbers': 'true',
            # You have to include theme file in 'css' or 'css_for_inplace' before using it.
            'theme': 'monokai',
        },
    },

    # Require users to be authenticated for uploading attachments.
    'attachment_require_authentication': True,

    # Set `upload_to` function for attachments.
    'attachment_upload_to': my_custom_upload_to_func(),

    # Set custom storage class for attachments.
    'attachment_storage_class': 'my.custom.storage.class.name',

    # Set custom model for attachments (default: 'django_summernote.Attachment')
    'attachment_model': 'my.custom.attachment.model', # must inherit 'django_summernote.AbstractAttachment'

    # You can completely disable the attachment feature.
    'disable_attachment': False,

    # Set to `True` to return attachment paths in absolute URIs.
    'attachment_absolute_uri': False,

    # test_func in summernote upload view. (Allow upload images only when user passes the test)
    # https://docs.djangoproject.com/en/2.2/topics/auth/default/#django.contrib.auth.mixins.UserPassesTestMixin
    ```
    def example_test_func(request):
        return request.user.groups.filter(name='group_name').exists()
    ```
    'test_func_upload_view': example_test_func,

    # You can add custom css/js for SummernoteWidget.
    'css': (
    ),
    'js': (
    ),

    # You can also add custom css/js for SummernoteInplaceWidget.
    # !!! Be sure to put {{ form.media }} in template before initiate summernote.
    'css_for_inplace': (
    ),
    'js_for_inplace': (
    ),

    # Codemirror as codeview
    # If any codemirror settings are defined, it will include codemirror files automatically.
    'css': (
        '//cdnjs.cloudflare.com/ajax/libs/codemirror/5.29.0/theme/monokai.min.css',
    ),

    # Lazy initialization
    # If you want to initialize summernote at the bottom of page, set this as True
    # and call `initSummernote()` on your page.
    'lazy': True,

    # To use external plugins,
    # Include them within `css` and `js`.
    'js': {
        '/some_static_folder/summernote-ext-print.js',
        '//somewhere_in_internet/summernote-plugin-name.js',
    },
}

You can style the editor via widget's attributes. These adhoc styling will override settings from SUMMERNOTE_CONFIG.

# Apply adhoc style via attributes
class SomeForm(forms.Form):
    foo = forms.CharField(widget=SummernoteWidget(attrs={'summernote': {'width': '50%', 'height': '400px'}}))

You can also pass additional parameters to custom Attachment model by adding attributes to SummernoteWidget or SummernoteInplaceWidget, any attribute starting with data- will be pass to the save(...) method of custom Attachment model as **kwargs.

# Pass additional parameters to Attachment via attributes
class SomeForm(forms.Form):
    foo = forms.CharField(widget=SummernoteWidget(attrs={'data-user-id': 123456, 'data-device': 'iphone'}))

TEST

Run tox. If you don't have it, just pip install tox

You can also run test with only specified targets.

$ tox -e py35-dj111, py38-dj301

LIMITATIONS

django-summernote does currently not support upload of non-image files.

LICENSE

django-summernote is distributed under MIT license and proudly served by great contributors.

Comments
  • Editor not loading for inline TextField

    Editor not loading for inline TextField

    Summernote is not loading for an inline model admin.

    I have an inline model:

    class ModelAInline(admin.StackedInline, SummernoteInlineModelAdmin):
        model = ModelA
        extra = 1
    
    class ModelBAdmin(SummernoteModelAdmin):
        ...
        inlines = [ModelAInline]
    
    admin.site.register(ModelB, ModelBAdmin)
    

    ModelB has a TextField which is loading with summernote widget correctly. ModelA has a TextField but it's not loading correctly, it just displays a white section, iframe doesn't seem to be loading.

    I found the following JS warnings on console:

    ReferenceError: content_iframe is not defined
    ReferenceError: __prefix__ is not defined
    

    Both JS errors point to line "32 > eval:1", referring, I think, to:

    eval("settings = window.parent.settings_id_modela_set-0-content/ line 32 &gt; eval_iframe;");
    

    I'am using version 0.5.12

    bug 
    opened by oromero 17
  • Server Error (500) with DEBUG=False

    Server Error (500) with DEBUG=False

    This is my first post to GitHub, so I am hopeful that I am submitting this information in the proper manner.

    I could not find this in documentation anywhere, but ran into an issue and a solution. I recommend updating the documentation for this solution.

    I setup Summernote in my Django3 Project. Everything looked perfect. I deployed to Heroku, but then could not access anything where Summernote was enabled. I was getting a Server Error (500). After checking quite a few different things, I realized the difference was that in my push to Heroku, my DEBUG is set to False. I changed this same setting in my dev environment and sure enough, same result.

    After hours of trying to track down the problem, I decided to move on for the time being and install a different Rich Text Editor. It was during the installation of that other editor where they had one line for their documentation. python manage.py collectstatic

    I realized that some static files had caused me problems previously, causing a 500 error when Debug was set to False. I figured, why not give this a try.

    Once I ran this, Summernote started working without issue.

    I pushed to Heroku, and everything is working as expected. Not a bug in the application, just recommending adding one line to the documentation.

    Thank you.

    opened by simpleittools 16
  • Not saving content while in code view?

    Not saving content while in code view?

    I'm using django-summernote 0.8.3 installed with mezzanine 4.1.0. After putting it in installed apps and adding a config to my settings.py, I just replaced all instances of admin.ModelAdmin in Mezzanine with SummernoteModelAdmin (there were only about 3 instances), and it seems to be working well.

    I use summernote to add html in a good syntax-colored, tab-preserving environment for pages. I noticed that if I edit the HTML and then press "Save" before turning off Code View, that my changes don't get loaded. Is there an easy fix to this?

    bug 
    opened by geoffrey-eisenbarth 14
  • django-summernote breaks after upgrading to Django 3

    django-summernote breaks after upgrading to Django 3

    After upgrading my app to Django 3 I get the following error:

    Traceback (most recent call last):
      File "manage.py", line 23, in <module>
        execute_from_command_line(sys.argv)
      File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
        utility.execute()
      File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 377, in execute
        django.setup()
      File "/usr/local/lib/python3.7/site-packages/django/__init__.py", line 24, in setup
        apps.populate(settings.INSTALLED_APPS)
      File "/usr/local/lib/python3.7/site-packages/django/apps/registry.py", line 114, in populate
        app_config.import_models()
      File "/usr/local/lib/python3.7/site-packages/django/apps/config.py", line 211, in import_models
        self.models_module = import_module(models_module_name)
      File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
      File "<frozen importlib._bootstrap>", line 983, in _find_and_load
      File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
      File "<frozen importlib._bootstrap_external>", line 728, in exec_module
      File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
      File "/source/lib/models.py", line 8, in <module>
        from django_summernote.widgets import SummernoteInplaceWidget
      File "/usr/local/lib/python3.7/site-packages/django_summernote/widgets.py", line 4, in <module>
        from django.contrib.staticfiles.templatetags.staticfiles import static
    ModuleNotFoundError: No module named 'django.contrib.staticfiles.templatetags'
    

    regarding to https://docs.djangoproject.com/en/dev/internals/deprecation/ that module was removed.

    After investigation of the Django sources replacing should be easy:

    # django 2.x django\contrib\staticfiles\templatetags\staticfiles.py
    def static(path):
        warnings.warn(
            'django.contrib.staticfiles.templatetags.static() is deprecated in '
            'favor of django.templatetags.static.static().',
            RemovedInDjango30Warning,
            stacklevel=2,
        )
        return _static(path)
    

    I think the problem may be that the package at https://pypi.org/project/django-summernote/ is outdated. It dates from January 2019. As the problem ist already fixed in the summernote sources only a new package needs to get published.

    opened by mpibpc-mroose 13
  • Forbidden <CSRF token missing or incorrect>:/ summernote/load_attachment/

    Forbidden :/ summernote/load_attachment/

    Hi I am getting this error when I try to load an image in the editor when I am using SummernoteInplaceWidget. The full error is:

    Forbidden :/ summernote/load_attachment/ POST /summernote/upload_attachment/ HTTP/1.1 403 2502

    When I use SummernoteWidget it works fine, but I can not resize the editor, but with SummernoteInplaceWidget I can resize it, but when I upload an image it show that error in console, and the image is not shown in the editor.

    I just want to say, that my header_photo is a ImageField and it works perfect, as SummernoteWidget does.

    my forms.py file:

    class CreatePostForm(forms.ModelForm):
    	class Meta:
    		model = Post
    		fields = ('title', 'status', 'header_photo', 'body')
    
    		widgets = {
                #'body': SummernoteWidget(),
                'body': SummernoteInplaceWidget(),
            }
    

    body is:

    body = models.CharField(max_length=5000, 
                                   blank=True, 
                                   unique=False, 
                                   null=True)
    

    settings.py file:

    STATIC_URL = '/static/'
    
    STATICFILES_DIRS = [
        os.path.join(BASE_DIR, 'static'),
        #'/var/www/static/',
    ]
    
    STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), 'static_cdn')
    
    MEDIA_URL = '/media1/'
    MEDIA_ROOT = os.path.join(os.path.dirname(BASE_DIR), 'media_cdn')
    
    
    SUMMERNOTE_CONFIG = {
        # Using SummernoteWidget - iframe mode
        'iframe': False,  # or set False to use SummernoteInplaceWidget - no iframe mode
    
        # Using Summernote Air-mode
        'airMode': False,
    
        # Use native HTML tags (`<b>`, `<i>`, ...) instead of style attributes
        # (Firefox, Chrome only)
        'styleWithTags': True,
    
        # Set text direction : 'left to right' is default.
        'direction': 'ltr',
    
        # Change editor size
        'width': '100%',
    
        # Max length
        'max-length': 5000,
    }
    

    and my form is:

    <form class="form-horizontal" method="post" action="." enctype="multipart/form-data">
                        {% csrf_token %}
                        <fieldset>
                            <div class="text-center" style="margin-bottom: 20px">
                                <h2 style="color: #c1b4b4;">Upload the header picture for your post</h2>
                                {% render_field post_form.header_photo class="form-control" style="background-color: #E8E8E8" %}
                            </div>
    
                            <div class="form-inline">
                                <div class="form-group" style="margin-bottom: 20px;">
                                    {% render_field post_form.title class="form-control" placeholder="Blog title" %}
                                    {% render_field post_form.status class="form-control" %}
                                </div>
                            </div>
                            {{ post_form.media }}
                            {{ post_form.body }}
                            <hr>
                            <div class="control-group">
                                <!-- Button -->
                                <div class="controls" style="margin-bottom: 20px">
                                    <button class="btn btn-lg btn-success" style="min-width: 300px">Save</button>
                                </div>
                            </div>
                            {% if redirect_field_value %}
                            <input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}" />
                            {% endif %}
                         </fieldset>
                    </form>
    

    If you need I can upload any of my files. Thank you for your help

    bug 
    opened by predragfalcic 13
  • Codemirror settings dont work in SummernoteInplaceWidget.

    Codemirror settings dont work in SummernoteInplaceWidget.

    In my form I use SummernoteInplaceWidget.

    I have 2 problems:

    1. I notice that when I open form bold button in toolbar is always active. I notice this bug in Firefox Mozilla but in other browsers it works fine. Also when I click to text which is without any style bold button became active. I notice this bug only in Firefox Mozilla. What do you this about that? default

    2. Why next my settings dont change codemirror? I want to add colors and line numbers. What can you advice to me? Where is my mistake?

    I want codemirror like this: default

    settings.py:

    SUMMERNOTE_CONFIG = {
       'css': {
            '//cdnjs.cloudflare.com/ajax/libs/codemirror/5.29.0/theme/monokai.min.css',
        },
       'codemirror': {
            'mode': 'htmlmixed',
            'lineNumbers': 'true',
            'theme': 'monokai',
        },
    }
    

    I load static files in template cause when I tried to set static files in settings.py file it raise error. CSS:

    <link rel="stylesheet" type="text/css" href="{% static "summernote/summernote.css" %}">
    <link rel="stylesheet" type="text/css" href="{% static "summernote/django_summernote.css" %}">
    <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/3.20.0/codemirror.css">
    <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/3.20.0/theme/monokai.css">
    

    JS:

    <script src="{% static 'summernote/jquery.ui.widget.js'%}"></script>
    <script src="{% static 'summernote/jquery.iframe-transport.js'%}"></script>
    <script src="{% static 'summernote/jquery.fileupload.js'%}"></script>
    <script src="{% static 'summernote/summernote.min.js'%}"></script>
    <script src="{% static 'summernote/ResizeSensor.js'%}"></script>
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/3.20.0/codemirror.js"></script>
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/3.20.0/mode/xml/xml.js"></script>
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/2.36.0/formatting.js"></script>
    

    Right now I have this: 1

    opened by nurzhannogerbek 9
  • fix multiplying '/static/' prefix

    fix multiplying '/static/' prefix

    the SummernoteInplaceWidget new media property introduced a regression where after successive reloads the widget stops working as the static files 'get lost'. the more reloads, the more static it gets :}

    <script type="text/javascript" src="/static/static/static/summernote/jquery.ui.widget.js"></script>
    <script type="text/javascript" src="/static/static/static/summernote/jquery.iframe-transport.js"></script>
    <script type="text/javascript" src="/static/static/static/summernote/jquery.fileupload.js"></script>
    <script type="text/javascript" src="/static/static/static/summernote/summernote.min.js"></script>
    <script type="text/javascript" src="/static/static/static/summernote/ResizeSensor.js"></script>
    

    using static() seems to be unnecessary:

    To find the appropriate prefix to use, Django will check if the STATIC_URL setting is not None and automatically fall back to using MEDIA_URL.

    i think that there is no advantage here to use the @property over the simpler Media class but in the patch i did not change it back.

    opened by minusf 9
  • Problem when using static file management with django + s3

    Problem when using static file management with django + s3

    hello.

    When doing staticfile management with django + s3 Django_summernote/templates/django_summernote/widget_iframe_editor.html : Problem with static tag in line 27.

    27 $.getScript('{% static "django_summernote/lang/summernote-" %}' + settings.lang + '.min.js');

    {% static "django_summernote/lang/summernote-" %} rendering => "https://{{s3-url}}/static/django_summernote/lang/summernote-" is not found error.

    The file 'django_summernote/lang/summernote-' could not be found with <xx.s3ext.StaticS3BotoStorage object at xxxx>.

    Due to this issue, we have temporarily created a "summernote-" file on s3.

    any ideas? help me.

    opened by jamieChae 9
  • drop-down menus isn't working

    drop-down menus isn't working

    django-summernote works, but drop-down menus isn't working. Style button and Line height buttons are virible, but doesn't roll out.

    Simple buttons are work well.

    Options taken from your readme.md. https://github.com/lqez/django-summernote#options 2014-08-29 12_02_28-example com _ edit org

    Example project already use the bootstrap - may be, some conflict?

    opened by yn-coder 9
  • Django 3.2 compatibility

    Django 3.2 compatibility

    Using the latest summernote (django-summernote==0.8.11.6) version results in some warnings:

    /usr/local/lib/python3.9/site-packages/django_summernote/urls.py:8: RemovedInDjango40Warning: django.conf.urls.url() is deprecated in favor of django.urls.re_path()
    

    and

    /usr/local/lib/python3.9/site-packages/django/apps/registry.py:91: RemovedInDjango41Warning: 'django_summernote' defines default_app_config = 'django_summernote.apps.DjangoSummernoteConfig'. Django now detects this configuration automatically. You can remove default_app_config.
    
    opened by BSVogler 8
  • Upgrade v0.8.7 to v0.8.8.5 FullScreen only show half height of window.

    Upgrade v0.8.7 to v0.8.8.5 FullScreen only show half height of window.

    I upgrade my Django from v1.11.5 to Django2.0,so i upgrade DjangoSummernote from v0.8.7 to 0.8.8.5.After upgrade i find full-screen not work like before.In v0.8.7 full-screen will resize SummernoteInplaceWidget to full screen,but in v0.8.8.5 SummernoteInplaceWidget only resize to about half of screen. 0.8.8.5: before full-screen after full-screen

    opened by yinkh 8
  • error when insert picture

    error when insert picture

    Internal Server Error: /summernote/upload_attachment/ Traceback (most recent call last): File "/home/nc/miniconda3/envs/django4.1/lib/python3.11/site-packages/django/core/handlers/exception.py", line 55, in inner response = get_response(request) ^^^^^^^^^^^^^^^^^^^^^ File "/home/nc/miniconda3/envs/django4.1/lib/python3.11/site-packages/django/core/handlers/base.py", line 197, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/nc/miniconda3/envs/django4.1/lib/python3.11/site-packages/django/views/generic/base.py", line 103, in view return self.dispatch(request, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/nc/miniconda3/envs/django4.1/lib/python3.11/site-packages/django/utils/decorators.py", line 46, in _wrapper return bound_method(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/nc/miniconda3/envs/django4.1/lib/python3.11/site-packages/django/views/decorators/clickjacking.py", line 36, in wrapped_view resp = view_func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/nc/miniconda3/envs/django4.1/lib/python3.11/site-packages/django_summernote/views.py", line 67, in dispatch return super(SummernoteUploadAttachment, self).dispatch(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/nc/miniconda3/envs/django4.1/lib/python3.11/site-packages/django/contrib/auth/mixins.py", line 135, in dispatch return super().dispatch(request, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/nc/miniconda3/envs/django4.1/lib/python3.11/site-packages/django/views/generic/base.py", line 142, in dispatch return handler(request, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/nc/miniconda3/envs/django4.1/lib/python3.11/site-packages/django_summernote/views.py", line 144, in post attachment.save(**kwargs) File "/home/nc/miniconda3/envs/django4.1/lib/python3.11/site-packages/django_summernote/models.py", line 22, in save super().save(*args, **kwargs) TypeError: Model.save() got an unexpected keyword argument 'gramm'

    opened by xuanblo 0
  • Why my src attribute ignored?

    Why my src attribute ignored?

    I installed django-summernote and followed all setup, however when I upload image and post it with text, img tag doesn't have src attribute.

    In db table, result is appeared like this,

     id |                 text
    ----+-------------------------------
      1 | <p>This is image.</p><p><br></p><img style="">
    

    I try to find solution. The reason was discovered in SummernoteTextFormField. When field saves data, field will run bleach.clean(). bleach will remove html tags, attributes, other things by settings what specified in settings.py So I open settings.py and found that there is no src attribute. After I wrote src in ATTRIBUTES, uploading image is successfully works.

     id |                                                               text                                                                
    ----+-----------------------------------------------------------------------------------------------------------------------------------
      1 |<p>This is image.</p><p><br></p><img src="http://127.0.0.1:8000/media/django-summernote/2022-10-07/b11642da-88a4-41c1-b509-b94a49371ad1.png" style="">
    

    I think this isn't good solution to avoid XSS. There must be reason why src attributes doesn't exist in settings.ATTRIBUTES.

    Before solve this problem, I got unexpected keyword argument error, #477. So I installed bleach-4.1.0. Is this cause above error?

    update: I solved this problem with below codes in project settings.py.

    from django_summernote.settings import ATTRIBUTES
    
    
    ATTRIBUTES["*"] += ["src",]
    
    opened by 10cheon00 0
  • docs: fix simple typo, attachement -> attachment

    docs: fix simple typo, attachement -> attachment

    There is a small typo in django_summernote/test_django_summernote.py.

    Should read attachment rather than attachement.

    Semi-automated pull request generated by https://github.com/timgates42/meticulous/blob/master/docs/NOTE.md

    opened by timgates42 0
  • Other boostrap theme not working correctly SUMMERNOTE_THEME = 'bs5'

    Other boostrap theme not working correctly SUMMERNOTE_THEME = 'bs5'

    With summernote 0.8.20, with in settings.py SUMMERNOTE_THEME = 'bs5', the widget is not working, at least in admin: What is looks like with default setting: image With `SUMMERNOTE_THEME = 'bs5': image

    The buttons, for example to select title and subtiles, are not working, neither the code formatting. There is also the code formatting issue with `SUMMERNOTE_THEME = 'bs4'.

    opened by Guilouf 1
Releases(0.8.19.0)
  • 0.8.19.0(Oct 14, 2021)

    Thank you to all contributors and users of django-summernote.

    • #405: Set X-Frame-Options setting on a per-view basis (@czlee)

    • #396: HTML escaping (@campfireman)

    • Bump Summernote to 0.8.19

    • Drop support for Python 2

    • Drop support for outdated Django versions

    And also thanks to @ulgens, @ncampuzano, @aathikahamed, and other contributors.

    Source code(tar.gz)
    Source code(zip)
  • 0.8.11.6(Dec 22, 2019)

  • 0.8.11.5(Dec 19, 2019)

    • Fix crispy-forms issue with SummernoteInplaceWidget (@wuuuduu)
    • Security fixes and CustomUserPassesTestMixin in SummernoteUploadAttachment view (@wuuuduu)
    • Update Travis / Tox settings for the latest Django and Python versions (@lqez)
    • Add test targets for Django 3.0+ (@lqez)
    • Replace test runner with pytest (@lqez)
    Source code(tar.gz)
    Source code(zip)
  • 0.8.11.4(Jan 4, 2019)

  • 0.8.11.1(Dec 10, 2018)

  • 0.8.11.0(Dec 10, 2018)

    • Update Summernote to 0.8.11
    • Fix import behaviour (thanks to Jorge Klemm)
    • Fix onBlurCodeview to use Summernote callback
    • Remove warning by removing regex at path() (thanks to Ant Somers)
    • Add Django 2.0 usage on README (thanks to Ant Somers)
    • Make test suite pass on Django master branch (thanks to Claude Paroz)
    • Fix widget rendering repeatly (thanks to Andrew Cordery)
    Source code(tar.gz)
    Source code(zip)
  • 0.8.10.0(Sep 1, 2018)

  • 0.8.8.8(Aug 13, 2018)

  • 0.8.8.7(May 9, 2018)

  • 0.8.8.6(Feb 8, 2018)

    • Remove duplicated codes into a mixin
    • Add a sample model for testing admin page manually
    • Add .flake8 setting
    • Rename summer_note to summernote
    • Changing the language loading to be synchronous
    • View import path fix
    • Change class-based view from function-based view
    • Add summernote_fields to control which fields will use summernote in admin.
    • Fix SummernoteInplaceWidget full screen not work bug.
    • Update latest summernote options for __summernote_options__
    • Fixes ResizeSensor.js: TypeError: window.getComputedStyle(...) is null

    Thank you all contributors!

    Source code(tar.gz)
    Source code(zip)
  • 0.8.8.5(Dec 11, 2017)

  • 0.8.8.4(Nov 23, 2017)

  • 0.8.8.3(Nov 21, 2017)

    • Allow user can add external plugin settings via dict.
    • Added check summernote language is not en-US when adding i18n script #236 (#237)
    • Fix the type of help_text in migration 0002 (#229)
    • Rename static directory (#241)
    • Form assets media as a dynamic property (#239)
    • Add some missing commas for SUMMERNOTE_CONFIG in README (#243)

    Thank you all, pals!

    Source code(tar.gz)
    Source code(zip)
Owner
Summernote
Done is better than perfect
Summernote
MAC address Model Field & Form Field for Django apps

django-macaddress MAC Address model and form fields for Django We use netaddr to parse and validate the MAC address. The tests aren't complete yet. Pa

49 Sep 04, 2022
Automatic class scheduler for Texas A&M written with Python+Django and React+Typescript

Rev Registration Description Rev Registration is an automatic class scheduler for Texas A&M, aimed at easing the process of course registration by gen

Aggie Coding Club 21 Nov 15, 2022
Django Rest Framework + React application.

Django Rest Framework + React application.

2 Dec 19, 2022
APIs for a Chat app. Written with Django Rest framework and Django channels.

ChatAPI APIs for a Chat app. Written with Django Rest framework and Django channels. The documentation for the http end points can be found here This

Victor Aderibigbe 18 Sep 09, 2022
This is a repository for collecting global custom management extensions for the Django Framework.

Django Extensions Django Extensions is a collection of custom extensions for the Django Framework. Getting Started The easiest way to figure out what

Django Extensions 6k Dec 26, 2022
Notes-Django: an advanced project to save notes in Django. where users are able to Create, Read, Update and Delete their notes.

An advanced software to keep you notes. It allows users to perform CRUD operations on theirs Notes. Was implemented Authorization and Authentication

Edilson Pateguana 1 Feb 05, 2022
Boilerplate Django Blog for production deployments!

CFE Django Blog THIS IS COMING SOON This is boilerplate code that you can use to learn how to bring Django into production. TLDR; This is definitely c

Coding For Entrepreneurs 26 Dec 09, 2022
Template for Django Project Using Docker

You want a Django project who use Docker and Docker-compose for Development and for Production ? It's for you !

1 Dec 17, 2021
A simple Django middleware for Duo V4 2-factor authentication.

django-duo-universal-auth A lightweight middleware application that adds a layer on top of any number of existing authentication backends, enabling 2F

Adam Angle 1 Jan 10, 2022
File and Image Management Application for django

Django Filer django Filer is a file management application for django that makes handling of files and images a breeze. Contributing This is a an open

django CMS Association 1.6k Dec 28, 2022
🔃 A simple implementation of STOMP with Django

Django Stomp A simple implementation of STOMP with Django. In theory it can work with any broker which supports STOMP with none or minor adjustments.

Juntos Somos Mais 32 Nov 08, 2022
A simple trivia quizzz web app made using django

Trivia Quizzz A simple trivia quizzz web app made using django Demo http://triviaquizzz.herokuapp.com/ & https://triviaquiz.redcrypt.xyz Features Goog

Rachit Khurana 2 Feb 10, 2022
A clone of https://virgool.io written in django

Virgool clone A clone of virgool blog written in django Installation first rename the .env.sample to .env and fill it. with docker docker-compose up -

Danial Selmipoor 7 Dec 23, 2022
Django models and endpoints for working with large images -- tile serving

Django Large Image Models and endpoints for working with large images in Django -- specifically geared towards geospatial tile serving. DISCLAIMER: th

Resonant GeoData 42 Dec 17, 2022
A real-time photo feed using Django and Pusher

BUILD A PHOTO FEED USING DJANGO Here, we will learn about building a photo feed using Django. This is similar to instagram, but a stripped off version

samuel ogundipe 4 Jan 01, 2020
Thumbnails for Django

Thumbnails for Django. Features at a glance Support for Django 2.2, 3.0 and 3.1 following the Django supported versions policy Python 3 support Storag

Jazzband 1.6k Jan 03, 2023
Full control of form rendering in the templates.

django-floppyforms Full control of form rendering in the templates. Authors: Gregor Müllegger and many many contributors Original creator: Bruno Renié

Jazzband 811 Dec 01, 2022
Django-powered application about blockchain (bitcoin)

Django-powered application about blockchain (bitcoin)

Igor Izvekov 0 Jun 23, 2022
A django model and form field for normalised phone numbers using python-phonenumbers

django-phonenumber-field A Django library which interfaces with python-phonenumbers to validate, pretty print and convert phone numbers. python-phonen

Stefan Foulis 1.3k Dec 31, 2022
Django Audit is a simple Django app that tracks and logs requests to your application.

django-audit Django Audit is a simple Django app that tracks and logs requests to your application. Quick Start Install django-audit pip install dj-au

Oluwafemi Tairu 6 Dec 01, 2022