Exemple #1
0
def page_not_found(request, template_name='404.html'):
    """
    404 (page not found) handler which uses Jinja2 to render the template.
    
    The default template is ``404.html``, and its context will contain
    ``request_path`` (the path of the requested URL) and any additional
    parameters provided by the registered context processors (this view uses
    ``RequestContext``).
    """

    context = RequestContext(request, {'request_path': request.path})
    response = context.render_response(template_name)
    response.status_code = 404
    return response
Exemple #2
0
def page_not_found(request, template_name="404.html"):

    """
    404 (page not found) handler which uses Jinja2 to render the template.
    
    The default template is ``404.html``, and its context will contain
    ``request_path`` (the path of the requested URL) and any additional
    parameters provided by the registered context processors (this view uses
    ``RequestContext``).
    """

    context = RequestContext(request, {"request_path": request.path})
    response = context.render_response(template_name)
    response.status_code = 404
    return response
Exemple #3
0
 def process_request(request):
     
     """
     Attach a special ``RequestContext`` subclass to each request object.
     
     This is the only method in the ``RequestContextMiddleware`` Django
     middleware class. It attaches a ``RequestContext`` subclass to each
     request as the ``Context`` attribute. This subclass has the request
     object pre-specified, so you only need to use ``request.Context()`` to
     make instances of ``django.template.RequestContext``.
     
     Consult the documentation for ``djanjinja.views.RequestContext`` for
     more information.
     """
     
     request.Context = RequestContext.with_request(request)
 def process_request(request):
     
     """
     Attach a special ``RequestContext`` subclass to each request object.
     
     This is the only method in the ``RequestContextMiddleware`` Django
     middleware class. It attaches a ``RequestContext`` subclass to each
     request as the ``Context`` attribute. This subclass has the request
     object pre-specified, so you only need to use ``request.Context()`` to
     make instances of ``django.template.RequestContext``.
     
     Consult the documentation for ``djanjinja.views.RequestContext`` for
     more information.
     """
     
     request.Context = RequestContext.with_request(request)