How do i create an associative array in django? i am new to python
models is a queryset
models = Models.objects.filter(year = 1999)
Essenstially i am looking to create something that has values:
for model in models:
newarray = {'item1' :model.item1 , 'item2' : model.item2}
it doesnt seem to work
i cant access newarray[0] or newarray[1] etc. What am I doing wrong here?
Python’s dictionaries are pure associative arrays; they cannot be accessed by numerical index. Use
newarray['item1']ornewarray['item2']instead.