При постраничном просмотре результатов значений словаря в djnago я получаю ошибку в виде нехешируемого типа: 'slice'.
Я пытаюсь вывести результаты (значения словаря) на html страницу. В процессе работы я получаю ошибку
unhashable type: 'slice'
views.py
from django.shortcuts import render
import urllib.request
import json
from django.core.paginator import Paginator
def display(request):
cities=['vijayawada','guntur','tenali','rajahmundry','amaravathi','Bengaluru','Mangaluru','Chikkamagaluru','Chennai']
data = {}
for city in cities:
source = urllib.request.urlopen(
'https://api.openweathermap.org/data/2.5/weather?q=' + city + '&units=metric&appid=APIID').read()
list_of_data = json.loads(source)
data[city] = {
"country_code": str(list_of_data['sys']['country']),
"coordinates": {
'latitude': str(list_of_data['coord']['lat']),
'longitude': str(list_of_data['coord']['lon'])
},
"temp": str(list_of_data['main']['temp']) + ' °C',
"pressure": str(list_of_data['main']['pressure']),
"humidity": str(list_of_data['main']['humidity']),
'main': str(list_of_data['weather'][0]['main']),
'description': str(list_of_data['weather'][0]['description']),
'icon': list_of_data['weather'][0]['icon'],
}
p = Paginator(data,3)
page = request.GET.get('page')
d = p.get_page(page)
context = {'data': d}
return render(request, 'display.html', context)
Помогите, пожалуйста, разбить на страницы значения в словаре
Я ожидаю постраничные результаты значений моего словаря