[Answer]-Django follow value foreign key in ajax json

1👍

One potential way around this is to construct your own dictionary object based on the returns of a queryset. You’d do something like this:

queryset = MyModel.objects.all()
list = [] #create list
    for row in queryset: #populate list
        list.append({'celular':row.celular, 'logo': row.logo, 'tipo': row.tipo.id})
    list_json = json.dumps(list) #dump list as JSON
    return HttpResponse(list_json, 'application/javascript')

Leave a comment