# Response.json() fields start with underscore

**URL:** <https://discuss.python.org/t/response-json-fields-start-with-underscore/72498>\
**Category:** Python Help\
**Tags:** help\
**Created:** [November 26, 2024, 10:12pm UTC](https://discuss.python.org/t/response-json-fields-start-with-underscore/72498 "2024-11-26T22:12:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ngregistrations](https://avatars.discourse-cdn.com/v4/letter/n/0ea827/32.png) [@ngregistrations](https://discuss.python.org/u/ngregistrations)\
**Post date:** [November 26, 2024, 10:12pm UTC](https://discuss.python.org/t/response-json-fields-start-with-underscore/72498/1 "2024-11-26T22:12:19Z")

</div>

Hi,

I am reading data from an API… and in the json it returns, some fields start with an underscore.

```python
    "_links": {
        "next": "/wiki/api/v2/spaces?cursor=eyJpZCI6NTIxOTk0MjcsInNwYWNlU29ydE9yZGVyIjp7ImZpZWxkIjoiSUQiLCJkaXJlY3Rpb24iOiJBU0NFTkRJTkcifSwic3BhY2VTb3J0T3JkZXJWYWx1ZSI6NTIxOTk0Mjd9",
        "base": "https://elkvalleyresources.atlassian.net/wiki"
    }

```

Here is how I defined my function in the views.py file

```python
    resp = requests.request("Get",uri, headers=headers, auth=userauth)
    
    response = resp.json()
    return render(request, 'spaces.html', {'response':response})

```

Here is how I display in the template.

```python
        {% for i in response.results %}
        <tr>
            <td>{{i.name}}</td>
            <td>{{i.type}}</td>
            <td>{{i.status}}</td>
            <td>{{i.createdAt}}</td>
            <td>{{i.id}}</td>
            <td>{{i.key}}</td>
            
            <td><a href="https://elkvalleyresources.atlassian.net/wiki">{{i.name}}</a> </td>
        </tr>
        {% endfor %}

```

but `response._links.next` fails with error: Variables and attributes may not begin with underscores: ‘response.\_links.next’

Also tried `response['_links']['next']`, also fails.

any help would be greatly appreciated.

thanks.  
NG.

---

<div class="post-metadata">

**Author:** ![MegaIng](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/megaing/32/16162_2.png) [@MegaIng](https://discuss.python.org/u/MegaIng)\
**Post date:** [November 26, 2024, 10:25pm UTC](https://discuss.python.org/t/response-json-fields-start-with-underscore/72498/2 "2024-11-26T22:25:27Z")

</div>

Googling for “Variables and attributes may not begin with underscores” gives a few results. Maybe one of those works for you?

Otherwise, please provide more information. The line `response._links.next` is not in the code you showed. Please give a complete example we can easily run on our machines without having to add any code.

Also, next time please mention that the error message is being produced by `django`, not by `requests`. `Response.json()` is not actually the function that fails. Also, please show complete tracebacks from error messages, they often contain useful information to make it easier for us to help you.

---

<div class="post-metadata">

**Author:** ![ngregistrations](https://avatars.discourse-cdn.com/v4/letter/n/0ea827/32.png) [@ngregistrations](https://discuss.python.org/u/ngregistrations)\
**Post date:** [November 26, 2024, 10:43pm UTC](https://discuss.python.org/t/response-json-fields-start-with-underscore/72498/3 "2024-11-26T22:43:52Z")

</div>

Thanks…

I will follow your advice… and google it…  
Also will follow your indication next time.
