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

前端 未结 9 1553
再見小時候
再見小時候 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:41

    It looks like the Django REST framework uses the HTTP accept header in a Request in order to automatically determine which renderer to use:

    http://www.django-rest-framework.org/api-guide/renderers/

    Using the HTTP accept header may provide an alternative source for your "if something".

提交回复
热议问题