class documentation

class RequestFactory:

Known subclasses: django.test.client.AsyncRequestFactory, django.test.client.Client

View In Hierarchy

Class that lets you create mock Request objects for use in testing.

Usage:

rf = RequestFactory() get_request = rf.get('/hello/') post_request = rf.post('/submit/', {'foo': 'bar'})

Once you have a request object you can pass it to any view function, just as if that view had been hooked up using a URLconf.

Method __init__ Undocumented
Method ​_base​_environ The base environment for a request.
Method ​_encode​_data Undocumented
Method ​_encode​_json Return encoded JSON if data is a dict, list, or tuple and content_type is application/json.
Method ​_get​_path Undocumented
Method delete Construct a DELETE request.
Method generic Construct an arbitrary HTTP request.
Method get Construct a GET request.
Method head Construct a HEAD request.
Method options Construct an OPTIONS request.
Method patch Construct a PATCH request.
Method post Construct a POST request.
Method put Construct a PUT request.
Method request Construct a generic request object.
Method trace Construct a TRACE request.
Instance Variable cookies Undocumented
Instance Variable defaults Undocumented
Instance Variable errors Undocumented
Instance Variable json​_encoder Undocumented
def __init__(self, *, json_encoder=DjangoJSONEncoder, **defaults):
def _base_environ(self, **request):
The base environment for a request.
def _encode_data(self, data, content_type):

Undocumented

def _encode_json(self, data, content_type):
Return encoded JSON if data is a dict, list, or tuple and content_type is application/json.
def _get_path(self, parsed):

Undocumented

def delete(self, path, data='', content_type='application/octet-stream', secure=False, **extra):
Construct a DELETE request.
def generic(self, method, path, data='', content_type='application/octet-stream', secure=False, **extra):
Construct an arbitrary HTTP request.
def get(self, path, data=None, secure=False, **extra):
Construct a GET request.
def head(self, path, data=None, secure=False, **extra):
Construct a HEAD request.
def options(self, path, data='', content_type='application/octet-stream', secure=False, **extra):
Construct an OPTIONS request.
def patch(self, path, data='', content_type='application/octet-stream', secure=False, **extra):
Construct a PATCH request.
def post(self, path, data=None, content_type=MULTIPART_CONTENT, secure=False, **extra):
Construct a POST request.
def put(self, path, data='', content_type='application/octet-stream', secure=False, **extra):
Construct a PUT request.
def request(self, **request):
Construct a generic request object.
def trace(self, path, secure=False, **extra):
Construct a TRACE request.
cookies =

Undocumented

defaults =

Undocumented

errors =

Undocumented

json_encoder =

Undocumented