I am learning how to handle JSON files in Django and I have successfully unpacked JSON, but now I would like to put it inside the table.
Is there a way to do that with pure HTML and using so called "tornado brackets" {{ }} not with jQuery / JS functions?
My code:
API BACKEND FILE
from requests import get
default_values = {
"repoName": "",
"repoURL": ""
}
def get_response():
response = get_json()
main_dictionary = {
"items":[]
}
try:
for repos in response:
main_dictionary["items"].append({
"repoName": repos["name"],
"repoURL": repos["html_url"]
})
except KeyError as error:
print("Key Error, check the validity of the keys you try to use to decode JSON")
return main_dictionary["items"]
def get_json():
first_response = get('https://api.github.com/users/jacobtoye/repos')
response = first_response.json()
return response
A FAILED ATTEMPT AT RENDERING PURE HTML TABLE
{% block content %}
<table>
<tr>
{% for repos in response %}
<td>{{ repoName }}</td>
{% if not forloop.last and forloop.counter == 3 or forloop.counter == 6 %}
</tr>
{% endif %}
<tr>
{% endfor %}
</tr>
</table>
The table doesn't show at all. I don't think that any other code files are substantial for this problem, but if you think you need more code, LMK I will gladly show you :)