mar*_*are 3 django http-headers mime-types django-class-based-views
我正在尝试这样做,但它不起作用。
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)
您不需要编写额外的代码。使用TemplateResponseMixin并将content_type属性设置为您需要的任何内容:
class MyView(TemplateResponseMixin):
content_type='application/xml'
...
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
11474 次 |
最近记录: |