Or rather, it's returning them as text, which is really odd. So I have this line of code in my javascript to test this that's
$.get('/static/js/categories.json', function(response){ console.log(response); });
I can verify that the actual location of the resource exists because the status code is 200, and I see responseText with the contents in the Chrome console window. Now the issue is that...
When I run it from the dev server locally there's only responseText
When I run it on the actual site, in the console, it returns responseJSON and responseText.
Does anyone know why this is the case? Essentially, it's not returning a javascript object
So the actual server runs apache. Is it possible that for some reason the Django dev server is setting the MIME types of responses incorrectly?
Apparent fix
Well it seems like this was the same problem encountered in this question. It was fixed by adding
if DEBUG:
import mimetypes
mimetypes.add_type("application/json", ".json", True)
In settings.py, but that doesn't answer the bigger question of WHY the development server can't correctly set the MIME type for some types of content
Edit
In fact, a lot of the mimetypes seem off. For instance, on my apache server .pngs are transferred as image/png while on the dev server it's image/x-png
Or rather, it's returning them as text, which is really odd. So I have this line of code in my javascript to test this that's
$.get('/static/js/categories.json', function(response){ console.log(response); });
I can verify that the actual location of the resource exists because the status code is 200, and I see responseText with the contents in the Chrome console window. Now the issue is that...
When I run it from the dev server locally there's only responseText
When I run it on the actual site, in the console, it returns responseJSON and responseText.
Does anyone know why this is the case? Essentially, it's not returning a javascript object
So the actual server runs apache. Is it possible that for some reason the Django dev server is setting the MIME types of responses incorrectly?
Apparent fix
Well it seems like this was the same problem encountered in this question. It was fixed by adding
if DEBUG:
import mimetypes
mimetypes.add_type("application/json", ".json", True)
In settings.py, but that doesn't answer the bigger question of WHY the development server can't correctly set the MIME type for some types of content
Edit
In fact, a lot of the mimetypes seem off. For instance, on my apache server .pngs are transferred as image/png while on the dev server it's image/x-png
0 commentaires:
Enregistrer un commentaire