mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-02-16 19:41:06 +03:00
documentation for request module
This commit is contained in:
parent
8b72b7bf92
commit
714a90d755
|
@ -40,7 +40,7 @@ __all__ = (
|
|||
|
||||
class RequestMixin(object):
|
||||
"""
|
||||
`Mixin` class to provide request parsing behavior.
|
||||
`Mixin` class to enhance API of Django's standard `request`.
|
||||
"""
|
||||
|
||||
_USE_FORM_OVERLOADING = True
|
||||
|
@ -50,15 +50,15 @@ class RequestMixin(object):
|
|||
|
||||
parsers = ()
|
||||
"""
|
||||
The set of request parsers that the view can handle.
|
||||
The set of parsers that the request can handle.
|
||||
|
||||
Should be a tuple/list of classes as described in the :mod:`parsers` module.
|
||||
"""
|
||||
|
||||
def get_request_class(self):
|
||||
"""
|
||||
Returns a custom subclass of Django's `HttpRequest`, providing new facilities
|
||||
such as direct access to the parsed request content.
|
||||
Returns a subclass of Django's `HttpRequest` with a richer API,
|
||||
as described in :mod:`request`.
|
||||
"""
|
||||
if not hasattr(self, '_request_class'):
|
||||
self._request_class = request_class_factory(self.request)
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
"""
|
||||
The :mod:`request` module provides a `Request` class that can be used
|
||||
to replace the standard Django request passed to the views.
|
||||
This replacement `Request` provides many facilities, like automatically
|
||||
parsed request content, form overloading of method/content type/content,
|
||||
better support for HTTP PUT method.
|
||||
The :mod:`request` module provides a :class:`Request` class that can be used
|
||||
to enhance the standard `request` object received in all the views.
|
||||
|
||||
This enhanced request object offers the following :
|
||||
|
||||
- content automatically parsed according to `Content-Type` header, and available as :meth:`request.DATA<Request.DATA>`
|
||||
- full support of PUT method, including support for file uploads
|
||||
- form overloading of HTTP method, content type and content
|
||||
"""
|
||||
|
||||
from django.http import HttpRequest
|
||||
|
@ -14,7 +17,7 @@ from djangorestframework.utils import as_tuple
|
|||
from StringIO import StringIO
|
||||
|
||||
|
||||
__all__ = ('Request')
|
||||
__all__ = ('Request',)
|
||||
|
||||
|
||||
def request_class_factory(request):
|
||||
|
@ -30,6 +33,9 @@ def request_class_factory(request):
|
|||
|
||||
|
||||
class Request(object):
|
||||
"""
|
||||
A mixin class allowing to enhance Django's standard HttpRequest.
|
||||
"""
|
||||
|
||||
_USE_FORM_OVERLOADING = True
|
||||
_METHOD_PARAM = '_method'
|
||||
|
|
5
docs/library/request.rst
Normal file
5
docs/library/request.rst
Normal file
|
@ -0,0 +1,5 @@
|
|||
:mod:`request`
|
||||
=====================
|
||||
|
||||
.. automodule:: request
|
||||
:members:
|
Loading…
Reference in New Issue
Block a user