Why my django app not including content-type on request headers?

I have simple Django app with some request send via ajax and django will return different responses depends on content-type I declare on ajax request. This code work fine on my local computer, however in my hosting server I always get 500 server error , it return keyerror: content-type. After checking headers list I notice that content-type not exist in the headers list on hosting, but in my local computer it exists.

Django lines:

if request.headers['content-type'] == 'application/json':
    response = render_to_string(self.templates, {'form': form}, request)
    data = {'success': True, 'rendered': response, 'title': self.title}
    return JsonResponse(data)
else:
    return render(request, 'base.html', {'form': form, 'title': self.title, 'template': self.templates})

AJAX Lines:

$.ajax({
    url: link,
    contentType: 'application/json',
    dataType: 'json',
    success: function(data){
        $('title').html(data.title);
        $('#content').html(data.rendered);
        window.history.pushState({'data': data, 'path': link}, "", link)
        $('#nav-menu').attr('data-path', link);

I confuse what the cause, I already collected staticfiles.

Back to Top