title: How to Use RESTful APIs with Django
body: <p>I have been trying to integrate a REST API developed using Django-rest framework with another Django web app. But stuck in passing JSON data into the front-end. I would appreciate any help. Here are my respective files.</p>
  <p>I have tried two different urls on views.py file, one is AWS API Gateway API, when used no errors are thrown but data is not displayed in front-end.</p>
  <p>AWS API JSON data where object is like {'key': 'value'}. it contains only one object though</p>
  <p><strong>views.py</strong></p>
  <pre><code>def ClientList(request):
        response = requests.get('A URL')
        client_data = response.json()
        return render(request, 'clients/client_list.html', context=client_data)
  </code></pre>
  <p>When I change the url in views.py for django-rest framework API then I get an error like &quot;<strong>the JSON object must be str, bytes or bytearray, not list</strong>&quot; JSON data where objects are like [{key: value},{key:value}, ...] Table body was changed accordingly.</p>
  <p><strong>FrontEnd HTML</strong></p>
  <pre><code>&lt;table class=&quot;table data-list-view&quot;&gt;
               &lt;thead&gt;
                 &lt;tr&gt;
                   &lt;th&gt;&lt;/th&gt;
                   &lt;th&gt;NAME&lt;/th&gt;
                   &lt;th&gt;EMAIL&lt;/th&gt;
                   &lt;th&gt;MOBILE&lt;/th&gt;
                   &lt;th&gt;ADDRESS&lt;/th&gt;
                   &lt;th&gt;ROLE&lt;/th&gt;
                   &lt;th&gt;ACTION&lt;/th&gt;
                 &lt;/tr&gt;
               &lt;/thead&gt;
               &lt;tbody&gt;
                 {% for client in client_data %}
                 &lt;tr&gt;
                   &lt;td&gt;&lt;/td&gt;
                   &lt;td class=&quot;product-name&quot;&gt;{{client.UserId}}&lt;/td&gt;
                   &lt;td class=&quot;product-category&quot;&gt;{{client.Height}}&lt;/td&gt;
                   &lt;td class=&quot;product-category&quot;&gt;{{client.Income}}&lt;/td&gt;
                   &lt;td class=&quot;product-category&quot;&gt;{{client.Age}}&lt;/td&gt;
                   &lt;td&gt;
              &lt;/td&gt;
                 &lt;/tr&gt;
                 {% endfor %}
              &lt;/tbody&gt;
            &lt;/table&gt;
  </code></pre>