JSON of course return json, but also normal web requests

This commit is contained in:
Oliver Falk
2021-04-21 15:15:02 +02:00
parent c5f493178c
commit a346bc6285

View File

@@ -411,7 +411,8 @@ class StatsView(TemplateView, JsonResponse):
'openids': ConfirmedOpenId.objects.all().count(), # pylint: disable=no-member
}
if request.content_type == 'application/json':
# JSON of course return json, but also normal web requests default to JSON
if request.content_type == 'application/json' or request.content_type == 'text/plain':
return JsonResponse(retval)
return HttpResponseRedirect(reverse_lazy('home'))