Determine the requested content type?
I'd like to write a Django view which serves out variant content based on what's requested. For example, for "text/xml", serve XML, for "text/json", serve JSON, etc. Is there a way to determine this from a request object? Something like this would be awesome: def process(request): if request.type == "text/xml": pass elif request.type == "text/json": pass else: pass Is there a property on HttpRequest for this? HttpRequest.META , more specifically HttpRequest.META.get('HTTP_ACCEPT') — and not HttpRequest.META.get('CONTENT_TYPE') as mentioned earlier 'Content-Type' header indicates media type