@@ -195,15 +195,41 @@ option.
195
195
Troubleshooting
196
196
---------------
197
197
198
- On some platforms, the Django ``runserver `` command may use incorrect content
199
- types for static assets. To guess content types, Django relies on the
200
- :mod: `mimetypes ` module from the Python standard library, which itself relies
201
- on the underlying platform's map files. If you find improper content types for
202
- certain files, it is most likely that the platform's map files are incorrect or
203
- need to be updated. This can be achieved, for example, by installing or
204
- updating the ``mailcap `` package on a Red Hat distribution, ``mime-support `` on
205
- a Debian distribution, or by editing the keys under ``HKEY_CLASSES_ROOT `` in
206
- the Windows registry.
198
+ If the toolbar doesn't appear, check your browser's development console for
199
+ errors. These errors can often point to one of the issues discussed in the
200
+ section below. Note that the toolbar only shows up for pages with an HTML body
201
+ tag, which is absent in the templates of the Django Polls tutorial.
202
+
203
+ Incorrect MIME type for toolbar.js
204
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
205
+
206
+ When this error occurs, the development console shows an error similar to:
207
+
208
+ .. code-block :: text
209
+
210
+ Loading module from “http://127.0.0.1:8000/static/debug_toolbar/js/toolbar.js” was blocked because of a disallowed MIME type (“text/plain”).
211
+
212
+ On some platforms (commonly on Windows O.S.), the Django ``runserver ``
213
+ command may use incorrect content types for static assets. To guess content
214
+ types, Django relies on the :mod: `mimetypes ` module from the Python standard
215
+ library, which itself relies on the underlying platform's map files.
216
+
217
+ The easiest workaround is to add the following to your ``settings.py `` file.
218
+ This forces the MIME type for ``.js `` files:
219
+
220
+ .. code-block :: python
221
+
222
+ import mimetypes
223
+ mimetypes.add_type(" application/javascript" , " .js" , True )
224
+
225
+ Alternatively, you can try to fix your O.S. configuration. If you find improper
226
+ content types for certain files, it is most likely that the platform's map
227
+ files are incorrect or need to be updated. This can be achieved, for example:
228
+
229
+ - On Red Hat distributions, install or update the ``mailcap `` package.
230
+ - On Debian distributions, install or update the ``mime-support `` package.
231
+ - On Windows O.S., edit the keys under ``HKEY_CLASSES_ROOT `` in the Windows
232
+ registry.
207
233
208
234
Cross-Origin Request Blocked
209
235
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
0 commit comments