Ticket #14744: fix-views-docs.diff

File fix-views-docs.diff, 3.1 KB (added by Adam Vandenberg, 14 years ago)
  • docs/topics/http/views.txt

    diff --git a/docs/topics/http/views.txt b/docs/topics/http/views.txt
    index 3ff11da..2818f42 100644
    a b Here's a view that returns the current date and time, as an HTML document:  
    2929
    3030Let's step through this code one line at a time:
    3131
    32     * First, we import the class ``HttpResponse``, which lives in the
    33       ``django.http`` module, along with Python's ``datetime`` library.
     32    * First, we import the class :class:`~django.http.HttpResponse` from the
     33      :mod:`django.http` module, along with Python's ``datetime`` library.
    3434
    3535    * Next, we define a function called ``current_datetime``. This is the view
    36       function. Each view function takes an ``HttpRequest`` object as its first
    37       parameter, which is typically named ``request``.
     36      function. Each view function takes an :class:`~django.http.HttpRequest`
     37      object as its first parameter, which is typically named ``request``.
    3838
    3939      Note that the name of the view function doesn't matter; it doesn't have to
    4040      be named in a certain way in order for Django to recognize it. We're
    4141      calling it ``current_datetime`` here, because that name clearly indicates
    4242      what it does.
    4343
    44     * The view returns an ``HttpResponse`` object that contains the
    45       generated response. Each view function is responsible for returning an
    46       ``HttpResponse`` object. (There are exceptions, but we'll get to those
    47       later.)
     44    * The view returns an :class:`~django.http.HttpResponse` object that
     45      contains the generated response. Each view function is responsible for
     46      returning an :class:`~django.http.HttpResponse` object. (There are
     47      exceptions, but we'll get to those later.)
    4848
    4949.. admonition:: Django's Time Zone
    5050   
    The Http404 exception  
    9797
    9898.. class:: django.http.Http404()
    9999
    100 When you return an error such as ``HttpResponseNotFound``, you're responsible
    101 for defining the HTML of the resulting error page::
     100When you return an error such as :class:`~django.http.HttpResponseNotFound`,
     101you're responsible for defining the HTML of the resulting error page::
    102102
    103103    return HttpResponseNotFound('<h1>Page not found</h1>')
    104104
    Three things to note about 404 views:  
    164164      to the template: ``request_path``, which is the URL that resulted
    165165      in the 404.
    166166
    167     * The 404 view is passed a ``RequestContext`` and will have access to
    168       variables supplied by your ``TEMPLATE_CONTEXT_PROCESSORS`` setting (e.g.,
    169       ``MEDIA_URL``).
     167    * The 404 view is passed a :class:`~django.template.RequestContext` and
     168      will have access to variables supplied by your
     169      :setting:`TEMPLATE_CONTEXT_PROCESSORS` setting (e.g.,
     170      :setting:`MEDIA_URL`).
    170171
    171     * If ``DEBUG`` is set to ``True`` (in your settings module), then your 404
    172       view will never be used, and the traceback will be displayed instead.
     172    * If :setting:`DEBUG` is set to ``True`` (in your settings module), then
     173      your 404 view will never be used, and the traceback will be displayed
     174      instead.
    173175
    174176The 500 (server error) view
    175177----------------------------
Back to Top