开发者

Django: check content_type of a request?

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜