I'd like to know if a request is HTML, CSS, image etc (in middleware).
I've tried:
print request.META['CONTENT_TYPE']
but that gives me:
text/plain
开发者_开发知识库
for everything, CSS and images alike.
Any advice?
Thanks!
I think you need to only be serving text based things through Django. Static media should be served through your production server. See this part of the docs
Secondly, you probably want to be checking the response, not the request.
Assuming you're using process_response, as Issac mentioned, you need to be looking at response.
精彩评论