Django speaking JSON

Heres the modified code: from django.shortcuts import get_object_or_404 @json_view def missing_person(request): person = get_object_or_404(Person, pk=1234) return {'found': True, 'person_id': person.pk} And here is the output correctly identifying HTTP 404 as the response code: ➫ curl -v localhost:8001/photos/missing_person/ ….< HTTP/1.0 404 NOT FOUND < Content-Type: application/json ….{"message": "No Person matches the given query.", "error": 404}. More details

Leave a Reply