Вы должны создавать объекты в цикле.Из кода видно, что вы создали объект incidentsServicenow
, созданный вне цикла.
for record in response.all():
data = {
'number': record['number'],
'description': record['description'],
'short_description': record['short_description'],
'state': record['state'],
}
#print(record['number'])
incidentsServicenow = IncidentsServicenow()
incidentsServicenow.number = data['number']
incidentsServicenow.title = data['short_description']
incidentsServicenow.description = data['description']
incidentsServicenow.state = data['state']
ticket.append(data)
print("storing data")
incidentsServicenow.save()
return HttpResponse(ticket, content_type='application/json')
или вы могли бы сделать это
for record in response.all():
data = {
'number': record['number'],
'description': record['description'],
'short_description': record['short_description'],
'state': record['state'],
}
#print(record['number'])
incidentsServicenow = IncidentsServicenow(number=data['number'],
title=data['short_description'],description=data['description'],state=data['state'])
ticket.append(data)
print("storing data")
incidentsServicenow.save()
return HttpResponse(ticket, content_type='application/json')