I am new to programming.. I used python to create code that gets data from an API using requests package and the request uses HTTPBasicAuth. Below is the request which works fine in genral python.
response = requests.get(url,auth=HTTPBasicAuth('username','password'),stream=True
Can some please advise how can I implement this in django. when I use the same code as below, it gives me an error as "name HTTPBasicAuth is not defined"
def index(request):
if request.method == "POST":
url = urlname
response = requests.get(url,auth=HTTPBasicAuth('username','password'),stream=True
data = response.json()