class CustomModel(model):
#some fields
def as_json(self):
return {
"id": self.id,
#other fields
}
objects = CustomModel.objects.filter(bla_bla_field = '1')
data = [ obj.as_json() for obj in objects]
return HttpResponse(json.dumps({"data": data}), content_type='application/json')