IMGIITRoorkee / django-filemanager

A simple Django app to browse files on server
MIT License
137 stars 75 forks source link

[ Beginner in Django]Refused to execute script because its MIME type #12

Open Merrick28 opened 8 years ago

Merrick28 commented 8 years ago

Hello,

I just tried this plugin, but I have an issue :

Refused to execute script from 'http://127.0.0.1:8000/abc/filemanager/js/script.js' because its MIME type ('image/png') is not executable.

Every script has the same error message in the console log (Chrome for Linux)

In my settings, I have :

STATIC_ROOT = os.path.join(BASE_DIR, 'static') STATIC_URL = '/static/' MEDIA_ROOT = '/home/steph/Téléchargements/'

I ran collectstatic, and I can see elements from filemanager in the "static" directory. The js url should not contain "static" somewhere ?

cfingerh commented 7 years ago

Had the same problem. I think it is caused because STATIC_URL is not rendered from the view to the template.

Changed the last lines of the init.py file to include the import of STATIC_URL and added to the context in the render

    from b2b.settings import STATIC_URL
    return render(request, 'filemanager/index.html', {
        'dir_structure': self.directory_structure(),
        'messages':map(str,messages),
        'current_id':self.current_id,
        'CKEditorFuncNum':CKEditorFuncNum,
        'ckeditor_baseurl':self.ckeditor_baseurl,
        'public_url_base':self.public_url_base,
        'space_consumed':space_consumed,
        'max_space':self.maxspace,
        'show_space':settings.FILEMANAGER_SHOW_SPACE,
        'STATIC_URL': STATIC_URL
    })
SanjoyPator1 commented 3 years ago

Hello,

I just tried this plugin, but I have an issue :

Refused to execute script from 'http://127.0.0.1:8000/abc/filemanager/js/script.js' because its MIME type ('image/png') is not executable.

Every script has the same error message in the console log (Chrome for Linux)

In my settings, I have :

STATIC_ROOT = os.path.join(BASE_DIR, 'static') STATIC_URL = '/static/' MEDIA_ROOT = '/home/steph/Téléchargements/'

I ran collectstatic, and I can see elements from filemanager in the "static" directory. The js url should not contain "static" somewhere ?

I am facing a similar problem when trying to add plugin in summernote i.e print option. Have you found the solution?

SanjoyPator1 commented 3 years ago

Had the same problem. I think it is caused because STATIC_URL is not rendered from the view to the template.

Changed the last lines of the init.py file to include the import of STATIC_URL and added to the context in the render

    from b2b.settings import STATIC_URL
    return render(request, 'filemanager/index.html', {
        'dir_structure': self.directory_structure(),
        'messages':map(str,messages),
        'current_id':self.current_id,
        'CKEditorFuncNum':CKEditorFuncNum,
        'ckeditor_baseurl':self.ckeditor_baseurl,
        'public_url_base':self.public_url_base,
        'space_consumed':space_consumed,
        'max_space':self.maxspace,
        'show_space':settings.FILEMANAGER_SHOW_SPACE,
        'STATIC_URL': STATIC_URL
    })

can you please tell me where is the init.py file where I have to add the static url