Can the Django dev server correctly serve SVG?

后端 未结 3 853
夕颜
夕颜 2020-12-01 05:32

I am trying to serve a svg map using:


    

        
      
      
      
3条回答
  •  醉梦人生
    2020-12-01 06:10

    If you're serving the SVG dynamically from a regular django view, you can specify the mimetype in the HTTPResponse object you return from that view. In this case, you'll want the mimetype in place for both dev and production use:

    def myview(request):
        svg_data = generate_some_svg_data()
        return HttpResponse(svg_data, mimetype="image/svg+xml")
    

提交回复
热议问题