def page_not_found(request, template_name='404.html'):
    """
    Custom page not found (404) handler.

    Don't raise a Http404 or anything like that in here otherwise
    you will cause an infinite loop. That would be bad.

    If no ResponsePage exists for with type ``RESPONSE_HTTP404`` then
    the default template render view will be used.

    Templates: :template:`404.html`
    Context:
        request_path
            The path of the requested URL (e.g., '/app/pages/bad_page/')
        page
            A ResponsePage with type ``RESPONSE_HTTP404`` if it exists.
    """
    rendered_page = get_response_page(
        request,
        http.HttpResponseNotFound,
        'icekit/response_pages/404.html',
        abstract_models.RESPONSE_HTTP404
    )
    if rendered_page is None:
        return defaults.page_not_found(request, template_name)
    return rendered_page