drf-mock-response
📦 A lightweight mock response framework for Django REST Framework (DRF).
Easily simulate API endpoints using static JSON files stored inside your Django apps.
🔧 Features
- Plug & play mock API views (List, Detail, Update, Delete)
- Supports
ViewSet-based mocks - Loads JSON mock data from
json_mock/directory inside each Django app - Customizable HTTP status code and response delay
- No real DB or models required
📁 Project Structure
In each Django app:
your_app/
├── json_mock/
│ └── your_mock.json
├── views/
│ └── your_mock_views.py
🚀 Installation
pip install git+https://github.com/khodealib/drf-mock-response.git
Or after cloning:
pip install /path/to/drf_mock_response/
🧩 Usage
# your_app/views/mocks.py
from drf_mock_response.views import MockListAPIView
class ProductListMock(MockListAPIView):
json_filename = "product_list.json"
mock_status = 200
delay_seconds = 1
# your_app/urls.py
from django.urls import path
from .views.mocks import ProductListMock
urlpatterns = [
path("mock/products/", ProductListMock.as_view()),
]
Place your mock file in:
your_app/json_mock/product_list.json
🔁 ViewSet Example
from drf_mock_response.viewsets import MockViewSet
class UserMockViewSet(MockViewSet):
json_filename = "user_list.json"
And wire it with a router in your urls.py.
✅ Requirements
Django ≥ 3.2
djangorestframework ≥ 3.14
📄 License
MIT © 2025 Ali Bagheri
Metadata
Release files for drf-mocker 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| drf_mocker-0.1.0.tar.gz | 5.5 kB | Without provenance | Details for drf_mocker-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| drf_mocker-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for drf_mocker-0.1.0-py3-none-any.whl |
Total release size: 10.2 kB
Release files / drf_mocker-0.1.0.tar.gz
| Download URL | drf_mocker-0.1.0.tar.gz |
|---|---|
| Size | 5.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
16d5cd0b4a81e31e51d401c8dafff73a6194707e0aa180bb515e446c02d4a6e8
|
|
BLAKE2b-256 checksum How to use checksums |
2a4cfc19fcdc79656de74d1849706ce69e2c62e4504f89e25349c1b84e8ae11e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.3
|
Release files / drf_mocker-0.1.0-py3-none-any.whl
| Download URL | drf_mocker-0.1.0-py3-none-any.whl |
|---|---|
| Size | 4.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1d9bd77e3379230d53adf7e0534bdfe546ebc017900878465faa531077a7cc19
|
|
BLAKE2b-256 checksum How to use checksums |
90bf22d608dc62663da2c7be9e9a14dead12f3b9189afcba7e580c211483df53
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.3
|
Security for drf-mocker 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.