Skip to main content
Django Request Mock
===================

Django Request Mock is an helper that allows you to generate synthetic request objects that mimic a real one, generated after a real request is being received by the framework.

Useful when coding in an HTTP isolated environment, which prevents you from accessing the request object, such as a cron method or a Celery task. This allows you to render templates and build absolute URIs from such contexts, for instance.

The request object is generated using your settings, and by default contains all the values of a request being sent to your website's default domain, using the SITE_URL configuration variable (can be of that form: https://example.com/)

## Configuration

* Ensure `SITE_URL` is defined in your **settings.py**, with a value such as 'https://example.com/'

* When you need to generate a request mock object, simply use the following code:

```python
from request_mock import request_mock

# Generate the mock object
# request_mock(base, path, user) where each argument is optional
request = request_mock()

# Can also be
request = request_mock(
base='https://other.org/',
path='/some/path/for/mock/request/',
user=User.objects.get(username='dummy.user')
)
```

* All done!

Metadata

Release files for django-request-mock 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-request-mock 0.1.4
File Size Uploaded
django-request-mock-0.1.4.tar.gz 2.6 kB Details

Release files / django-request-mock-0.1.4.tar.gz

Download URL django-request-mock-0.1.4.tar.gz
Size 2.6 kB
Tags Source
SHA-256 checksum
How to use checksums
c9db369ee9ed004e8d468ed42d1db74ee8f452942c498d1e18e2cdf981faab99
BLAKE2b-256 checksum
How to use checksums
c1778e369e3f5c965c54e426d6ae2a8f9ef6c01cb90ec6641152340e8a48227c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.4 This release

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page