AP257
AP257

Reputation: 93773

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!

Upvotes: 2

Views: 580

Answers (2)

gcbirzan
gcbirzan

Reputation: 1514

Assuming you're using process_response, as Issac mentioned, you need to be looking at response.

Upvotes: 0

Issac Kelly
Issac Kelly

Reputation: 6359

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.

Upvotes: 1

Related Questions