Determine the requested content type?

前端 未结 4 968
不知归路
不知归路 2020-12-18 18:49

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. I

4条回答
  •  时光说笑
    2020-12-18 19:05

    HttpRequest.META, more specifically HttpRequest.META.get('HTTP_ACCEPT') — and not HttpRequest.META.get('CONTENT_TYPE') as mentioned earlier

提交回复
热议问题