Get json from one view by calling it from another view

后端 未结 3 1827
闹比i
闹比i 2020-12-21 08:14

I have a view that returns JSON data. I want to get that data from another view as well, so I tried calling the JSON view from it. However, a Response was ret

3条回答
  •  情话喂你
    2020-12-21 09:01

    The decorator of a view-function can convert your return-value in a Response object depending on it's type (more information about these rules check out here). The json data is stored in r.response where r is the Response object.

    The better solution is to create a separate function, which returns the json data, which can be called from two different view-functions.

提交回复
热议问题