Django - Using CSRF Token

Hello, How can i delete the csrftoken in views? I am doings this to get new csrftoken whenever the webpage is reloaded from the client(reactjs). I also added x-csrftoken attribute to my response so that i can use the token when sending a request from other endpoints. I tried using rotate_token but it returns None. Another problem that I have is that, csrftoken in the browser does not change whenever i sent a request to get_csrf view.

@api_view(['GET'])
@xframe_options_deny
@cache_page(0)
def get_csrf(request):
    response = Response({
        'x-csrftoken': get_token(request)
    })

    for cookie in request.COOKIES:
        response.delete_cookie(cookie)

    return response

Solution

@api_view(['GET'])
@xframe_options_deny
@cache_page(0)
def get_csrf(request):

    try:
        csrf_cookie = request.META['CSRF_COOKIE']
    except KeyError:
        response = Response({
            'x-csrftoken': get_token(request)
        })
    else:
        response = Response({
            'x-csrftoken': csrf_cookie
        })

    return response