mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-02-21 14:05:16 +03:00
documentation for request module
This commit is contained in:
parent
8b72b7bf92
commit
714a90d755
|
@ -40,7 +40,7 @@ __all__ = (
|
||||||
|
|
||||||
class RequestMixin(object):
|
class RequestMixin(object):
|
||||||
"""
|
"""
|
||||||
`Mixin` class to provide request parsing behavior.
|
`Mixin` class to enhance API of Django's standard `request`.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
_USE_FORM_OVERLOADING = True
|
_USE_FORM_OVERLOADING = True
|
||||||
|
@ -50,15 +50,15 @@ class RequestMixin(object):
|
||||||
|
|
||||||
parsers = ()
|
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.
|
Should be a tuple/list of classes as described in the :mod:`parsers` module.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def get_request_class(self):
|
def get_request_class(self):
|
||||||
"""
|
"""
|
||||||
Returns a custom subclass of Django's `HttpRequest`, providing new facilities
|
Returns a subclass of Django's `HttpRequest` with a richer API,
|
||||||
such as direct access to the parsed request content.
|
as described in :mod:`request`.
|
||||||
"""
|
"""
|
||||||
if not hasattr(self, '_request_class'):
|
if not hasattr(self, '_request_class'):
|
||||||
self._request_class = request_class_factory(self.request)
|
self._request_class = request_class_factory(self.request)
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
"""
|
"""
|
||||||
The :mod:`request` module provides a `Request` class that can be used
|
The :mod:`request` module provides a :class:`Request` class that can be used
|
||||||
to replace the standard Django request passed to the views.
|
to enhance the standard `request` object received in all the views.
|
||||||
This replacement `Request` provides many facilities, like automatically
|
|
||||||
parsed request content, form overloading of method/content type/content,
|
This enhanced request object offers the following :
|
||||||
better support for HTTP PUT method.
|
|
||||||
|
- 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
|
from django.http import HttpRequest
|
||||||
|
@ -14,7 +17,7 @@ from djangorestframework.utils import as_tuple
|
||||||
from StringIO import StringIO
|
from StringIO import StringIO
|
||||||
|
|
||||||
|
|
||||||
__all__ = ('Request')
|
__all__ = ('Request',)
|
||||||
|
|
||||||
|
|
||||||
def request_class_factory(request):
|
def request_class_factory(request):
|
||||||
|
@ -30,6 +33,9 @@ def request_class_factory(request):
|
||||||
|
|
||||||
|
|
||||||
class Request(object):
|
class Request(object):
|
||||||
|
"""
|
||||||
|
A mixin class allowing to enhance Django's standard HttpRequest.
|
||||||
|
"""
|
||||||
|
|
||||||
_USE_FORM_OVERLOADING = True
|
_USE_FORM_OVERLOADING = True
|
||||||
_METHOD_PARAM = '_method'
|
_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