def _create_mock_json_request(user, data, method='POST'):
 factory = RequestFactory()
 request = factory.generic(method, '/', content_type='application/json', data=json.dumps(data))
 request.user = user
 request.session = {}
 return request

def _create_mock_json_request ( user , data , method = 'POST' ) : factory = RequestFactory ( ) request = factory . generic ( method , '/' , content_type = 'application/json' , data = json . dumps ( data ) ) request . user = user request . session = { } return request
returns a mock json request for the specified user .