I Have a Django app which use api written i ASP.Net. I can call api from template (html page). Is there any way to call api from views.py? I have tried this.
from django.shortcuts import render
from django.contrib.auth.decorators import login_required
# Create your views here.
def categorydashboard(request):
r = request.get('xxx.xxx.xx.xxx:xxxx/Category/getSubCategoryNamev2', d=request.GET)
return render (request,'categoryDashboard.html',{})
API sample data (it is a GET request)
[
{
"category_id": 2,
"category_name": "Hyper Mechanical",
"Image_Path": null,
"subcategory": [
{
"category_id": 0,
"category_name": null,
"product_subcategory_id": 37,
"product_subcategory_name": "Lift",
"schema_id": null,
"Image_path": ""
}
]
}
]
Server runs well but when i call 'categorydashboard' view its throws following error AttributeError: 'WSGIRequest' object has no attribute 'get' I am new in Django so i am sorry if i have mistaken