Django-summernote image upload

I recently implemented django-summernote with my forms that fit text well. However, I am struggling to understand how image loading works. Does anyone know how to do this?

Problem

When selecting an image from a file using Summernote, the Insert Image button is disabled (works great for image links). I have not written a custom function 'upload_to', but as I understood it, this is already done in django-summernote.

More details

  • Installed django-summernote according to the documentation.
  • Added summernote for urls and in INSTALLED_APPS
  • Added lettering to the form field

    direction = forms.CharField (widget = SummernoteInplaceWidget (ATTRS = {'MaxLength': '4000'}), required = False,)

  • Also added some configuration to SUMMERNOTE_CONFIG (settings.py)

    SUMMERNOTE_CONFIG = {
        'iframe': True,
    
        'airMode': True,
    
        'width': '100%',
        'height': '300',
    
          'toolbar': [
            # ['style', ['style']],
            ['font', ['bold', 'italic', 'underline', 'superscript', 'subscript', 'strikethrough', 'clear']],
            # ['fontname', ['fontname']],
            ['fontsize', ['fontsize']],
            # ['color', ['color']],
            ['para', ['ul', 'ol', 'paragraph']],
            ['height', ['height']],
            ['table', ['table']],
            ['insert', ['link', 'picture', 'video', 'hr']],
            ['view', ['fullscreen', 'codeview']],
            ['help', ['help']],
          ], }
    
          

Should I also write my own backend for attachments (images)? STATIC_URL and MEDIA_URL are defined in my .py settings, if relevant for this problem.

Update November 29, 2014:

Selecting an image in the console displays the following error: "undefined is not a function" which is associated with

imageInput.fileupload();

      

The Insert Image button is disabled.

As my project is in development mode, I have DEBUG = True in my settings.

My urls look like this:

urlpatterns += patterns('',
  url(r'^summernote/', include('django_summernote.urls')),
  ) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

      

and Media_root and Media_url are set to the following values:

MEDIA_ROOT = path.join(path.dirname(__file__), 'media',)
MEDIA_URL = '/media/'

      

I am using image uploads outside of django-summernote with these settings.

It looks like I'm missing something but can't figure out what.

Thanks in advance.

+3


source to share


1 answer


django-summernote

comes with backend support for loading images out of the box. This way you don't need to write your own server for this. The settings MEDIA_ROOT

or MEDIA_URL

may be incorrect for the boot problem - permission or invalid path.

Run django project with runserver

and please check browser console (check) and python console after image upload.



And also link to Need a minimal Django file upload example to process files in a django project.

0


source







All Articles