Ticket #6181: document-view-decorators.diff

File document-view-decorators.diff, 3.2 KB (added by Adam Vandenberg, 13 years ago)

Add docs missing for a few view decorators, and link to existing docs for already documented ones.

  • docs/index.txt

    diff --git a/docs/index.txt b/docs/index.txt
    index 632adc8..0cf066e 100644
    a b The view layer  
    9191    * **The basics:**
    9292      :doc:`URLconfs <topics/http/urls>` |
    9393      :doc:`View functions <topics/http/views>` |
    94       :doc:`Shortcuts <topics/http/shortcuts>`
     94      :doc:`Shortcuts <topics/http/shortcuts>` |
     95      :doc:`Decorators <topics/http/decorators>`
    9596
    9697    * **Reference:**
    9798      :doc:`Request/response objects <ref/request-response>` |
  • docs/topics/cache.txt

    diff --git a/docs/topics/cache.txt b/docs/topics/cache.txt
    index dd3fd78..4c35cd4 100644
    a b exist to instruct upstream caches to differ their cache contents depending on  
    964964designated variables, and to tell caching mechanisms not to cache particular
    965965pages. We'll look at some of these headers in the sections that follow.
    966966
     967.. _using-vary-headers:
     968
    967969Using Vary headers
    968970==================
    969971
  • new file docs/topics/http/decorators.txt

    diff --git a/docs/topics/http/decorators.txt b/docs/topics/http/decorators.txt
    new file mode 100644
    index 0000000..641433e
    - +  
     1===============
     2View Decorators
     3===============
     4
     5.. currentmodule:: django.views.decorators.http
     6
     7Django provides several decorators that can be applied to views to support
     8various HTTP features.
     9
     10Allowed HTTP Methods
     11====================
     12
     13.. function:: require_http_methods(request_method_list)
     14
     15This decorator is used to make a view only accept particular request methods.
     16Usage::
     17
     18    @require_http_methods(["GET", "POST"])
     19    def my_view(request):
     20        # I can assume now that only GET or POST requests make it this far
     21        # ...
     22
     23Note that request methods should be in uppercase.
     24
     25.. function:: require_GET
     26
     27Decorator to require that a view only accept the GET method.
     28
     29.. function:: require_POST
     30
     31Decorator to require that a view only accept the POST method.
     32
     33Conditional view processing
     34===========================
     35
     36.. function:: condition(etag_func=None, last_modified_func=None)
     37
     38.. function:: etag(etag_func)
     39
     40.. function:: last_modified(last_modified_func)
     41
     42These decorators can be used to generate ``ETag`` and ``Last-Modified``
     43headers; see
     44:doc:`conditional view processing </topics/conditional-view-processing>`.
     45
     46.. currentmodule:: django.views.decorators.http
     47
     48GZip Compression
     49================
     50
     51.. function:: gzip_page()
     52
     53This decorator compresses content if the browser allows gzip compression.
     54It sets the ``Vary`` header accordingly, so that caches will base their
     55storage on the ``Accept-Encoding`` header.
     56
     57.. currentmodule:: django.views.decorators.vary
     58
     59Vary Headers
     60============
     61
     62The ``Vary`` header defines which request headers a cache mechanism should take
     63into account when building its cache key.
     64
     65.. function:: vary_on_cookie(func)
     66
     67.. function:: vary_on_headers(*headers)
     68
     69See :ref:`using vary headers <using-vary-headers>`.
  • docs/topics/http/index.txt

    diff --git a/docs/topics/http/index.txt b/docs/topics/http/index.txt
    index 5ef776d..0bcb3a2 100644
    a b Information on handling HTTP requests in Django:  
    88   
    99   urls
    1010   views
     11   decorators
    1112   file-uploads
    1213   shortcuts
    1314   generic-views
Back to Top