小编mar*_*are的帖子

Django:如何在基于类的视图中将内容类型标头设置为 text/xml?

我正在尝试这样做,但它不起作用。

class MyView(View):

    def options(self, request, *args, **kwargs):
        """
        Handles responding to requests for the OPTIONS HTTP verb.
        """
        response = http.HttpResponse()
        if self.kwargs.has_key('xml'):
            response['Content-Type'] = 'text/xml; charset=utf-8'
        return response
Run Code Online (Sandbox Code Playgroud)

django http-headers mime-types django-class-based-views

3
推荐指数
1
解决办法
1万
查看次数