Answer the question
In order to leave comments, you need to log in
How to add headers for json response?
Please help me to add http header to JSON format response:
def result(request, date_from, date_to, user_id):
results = Result.objects.filter(
user_id=user_id,
created_date__gte=date_from[0:10],
created_date__lte=date_to[0:10],
)
results_serialized = serializers.serialize('json', results)
return JsonResponse(results_serialized, safe=False)
Answer the question
In order to leave comments, you need to log in
response = JsonResponse(results_serialized, safe=False)
response['some-header'] = 42
return response
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question