запросов на импорт
из django.shortcuts импорт рендеринга
из .модели импорт город
из .form import CityForm
def about (запрос):
url = "http://api.openweathermap.org/data/2.5/weather?APPID=0b403d8cbc641f739c3c2547ccd9cf75&q="
if request.method == 'POST':
pass
form = CityForm(request.get)
cities = City.objects.all()
response = requests.get(url)json()
city_weather_details = {
'City': city.name,
'description':response['weather'][0]['description'],
'Windspeed':response['wind']['speed'],
'Icon':response['weather'][0]['icon'],
'Temperature':response['main']['temp'],
}
context = {'city_weather_details,' : city_weather_details, 'form':form}
return render(request,'weather/weather.html', context)