I'm building a basic Django site.
Currently, I'm trying figure out a way to make an API call and retrieve the results on page load.
Is it possible to use the js .onload function to call a Django view function?
Any suggestions/tips would be appreciated!
elkhayyat :
you can use "requests" library and making a request on the django view for this page.\nimport requests\n\ndef my_view(request):\n r = requests.get('https://api.github.com/user', auth=('user', 'pass'))\n context = {\n 'data': r.json()\n }\n return render(request, 'my_html.html', context)\n",
2021-12-24T14:00:17