def csrf_token(context):
    csrf_token = context.get('csrf_token', '')
    if csrf_token == 'NOTPROVIDED':
        return ''
    return u'<div style="display:none"><input type="hidden" name="csrfmiddlewaretoken" value="%s" /></div>' % (csrf_token)

# In your mako rendering function, whichever that is,
# add "csrf_token" to the context as such:

def render_mako(request, view_name, template_name, **kwargs):
    """
    Renders the template given the name of it and the request to add the request
    to the context.
    """
    from django.core.context_processors import csrf

    # ...
    kwargs['csrf_token'] = csrf(request)['csrf_token']
    # ...
