Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Merrick28 opened this issue Aug 5, 2016 · 3 comments
Open

Comments

@Merrick28
Copy link

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
Copy link

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
Copy link

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants