Here is the code for the next lecture -  is_ajax function will be used to check if the request is n AJAX (Asynchronous JavaScript and XML) request or not:

 def is_ajax(request):
    return request.headers.get('x-requested-with') == 'XMLHttpRequest'