Django - Unable to render it through api genrated json file

I am trying to display sunrise from the below dict file but I would get the value: 1618358103 only but i need to display sunrise instead. please review the below code along with Django file.

def homeView(request):
views = {}
city = “Kathmandu”
url = f"{city} &appid=dd799068b7ecc1b7446b9588d15e7e0e"
data = requests.get(url).json()
# print(data)
payload = {‘city’: data[‘name’],
‘weather’ : data[‘weather’][0][‘main’],
‘icon’: data[‘weather’][0][‘icon’],
‘kelvin_temperature’: data[‘main’][‘temp’],
‘celcius_temperature’: data[‘main’][‘temp’] - 273,
‘pressure’: data[‘main’][‘pressure’],
‘humidity’: data[‘main’][‘humidity’],
‘sunrise’: data[‘sys’] [‘sunrise’]

my_dict2 = {'data': payload}
date =
date = date.strftime("%c")
my_dict = {'date_msg': date}
views['navbar'] = navbar.objects.all()
return render(request, 'index.html', context={'date_msg': date, 'data': payload})


  • {{data.celcius_temperature}}ºc,Sunny{{data.humidity}} {**{data.sunrise}}**
  • {{date_msg}}

output: 1618358103 instead i need to print sunrise which is key.

Please post a sample of the JSON data you’re receiving from that API.

(Also, when you’re posting code, templates, or data here, please enclose it between two lines of three backtick - ` characters. This means you’ll have a line of ```, then your code, then another line of ```. This ensures that the code remains formatted correctly.)

1 Like

Actually, I just recognized this as a Unix Epoch time - translates to April 13 @ 11:55:03 PM UTC. See the Python datetime module for options to convert this to a localized timestamp value.

1 Like

JSON file

The schema definition for this data is provided in the api docs. You can find everything there you need to convert these values to human-readable forms.