Answer the question
In order to leave comments, you need to log in
Open Weather API Map - How to make in Celsius?
Hello, I want to add a widget to a website in Django using the Open Weather API Map.
views.py
from django.shortcuts import render
import requests
def weather(request):
url = 'http://api.openweathermap.org/data/2.5/weather?q={}&units=CODEAPI'
city = 'Kaliningrad'
city_weather = requests.get(url.format(city)).json()
weather = {
'city': city,
'temperature': city_weather['main']['temp'],
'description': city_weather['weather'][0]['description'],
'icon': city_weather['weather'][0]['icon']
}
context = {'weather': weather}
return render(request, 'admin/weather.html', context)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question