How do I return JSON without using a template in Django?

前端 未结 9 1620
再見小時候
再見小時候 2020-12-04 07:01

This is related to this question: Django return json and html depending on client python


I have a command line Python API for a Django app. When I access the a

9条回答
  •  余生分开走
    2020-12-04 07:42

    You could also check the request accept content type as specified in the rfc. That way you can render by default HTML and where your client accept application/jason you can return json in your response without a template being required

提交回复
热议问题