'Returns the currently active CSRF token from the session,
generating a new one if needed.'

def get_csrf_token(self, request):

    token = request.session.get(self.key, None)
    if (not token):
        token = self.new_csrf_token(request)
    return token
