I'm using Python 3.7 and Django. I have a view that returns the following
# Ajax request that returns articles with similar words in the titles
def get_hints(request):
...
s = ArticlesService()
objects = s.get_hints(article)
data = serializers.serialize('json', objects)
return HttpResponse(data, content_type="application/json")
The "get_hints" method returns an array of model objects. The thing is, on the Javascript side, the JSON is returned like so ...
[{model: "mydb.article", pk: 60945, fields: { title: "Cooking Eggplant", path: "https://thecookingblog.com/abcde", label: "" },
...]
Is there a way to have the JSON returned without the "model" and "fields" and just have the object's attribute returned as more traditional JSON, e.g.
{ title: "Cooking Eggplant", path: "https://thecookingblog.com/abcde", label: "" }
?