API Formatter fixes

This commit is contained in:
Martin Mahner 2018-06-22 13:21:08 +02:00
parent 7b99cbab6e
commit 227e36ce35

View file

@ -257,12 +257,13 @@ class APIView(View):
) )
s.save() s.save()
# Custom formatter for the API response
formatter = getattr(self, '_format_{0}'.format(response_format), None) formatter = getattr(self, '_format_{0}'.format(response_format), None)
if formatter: if callable(formatter):
response = self._format_default(s) return HttpResponse(formatter(s))
else:
response = formatter(s) # Otherwise use the default one.
return HttpResponse(response) return HttpResponse(self._format_default(s))
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------