DEV Community

NG
NG

Posted on

Python response.json() fields starting with "_"

Hi everyone..

Wonder if any can point me in the right direction...

I define a function in the views.py file to get data from an API... but in the json that is returned, some of the fields start with and underscore.

Image description

Here is my function:

Image description

So, I am outputing this data in a webpage, when I loop through the results, it works... by calling the objects

response.results
Enter fullscreen mode Exit fullscreen mode

But when I try

response._link
Enter fullscreen mode Exit fullscreen mode

then it fails. Here is how it looks like in the code.

Image description

The error I get is : Variables and attributes may not begin with underscores: 'response._links.next'

I tried response[_link][next] did not work.
I need to capture that NEXT, as it is the pagination offered by this API, so I can continue to get all the records.

Any help will be appreciated.
Thanks.
NG

Top comments (0)