Skip to content

Documentation: simplify troubleshooting of incorrect mime types for .js static files #2046

Closed
@blep

Description

@blep

The troubleshooting documentation makes it difficult for new Django developers like me who follow the Django tutorial and run into an issue:
https://django-debug-toolbar.readthedocs.io/en/latest/installation.html#troubleshooting

  • First, it should tell you to check the console window for message about incorrect MIME type when loading toolbar.js (was text/plain for me, running on Windows O.S.). For me the error message was (sorry, in French):
    Le chargement du module à l’adresse « http://localhost:8000/static/debug_toolbar/js/toolbar.js » a été bloqué en raison d’un type MIME interdit (« text/plain »).
  • Second, the workarounds are complexe, involve global system configuration changes, are missing detailed steps and need to be performed on each developer's machine.

A much simpler work-around is to add the following to your settings.py, which forces the MIME type of .js files:

import mimetypes
mimetypes.add_type("application/javascript", ".js", True)

This resolved the issue for me without system-wide change.
May even want to add these steps as part of the installation instruction, to ensure it runs on any system.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions