A Django DRF mock response tool
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file drf_mocker-0.1.0.tar.gz.
File metadata
- Download URL: drf_mocker-0.1.0.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
16d5cd0b4a81e31e51d401c8dafff73a6194707e0aa180bb515e446c02d4a6e8
|
|
| MD5 |
b9905e668ea065244b4d789e709a7ec6
|
|
| BLAKE2b-256 |
2a4cfc19fcdc79656de74d1849706ce69e2c62e4504f89e25349c1b84e8ae11e
|
File details
Details for the file drf_mocker-0.1.0-py3-none-any.whl.
File metadata
- Download URL: drf_mocker-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1d9bd77e3379230d53adf7e0534bdfe546ebc017900878465faa531077a7cc19
|
|
| MD5 |
9aff66037924bb357ccbc8e10cb351c9
|
|
| BLAKE2b-256 |
90bf22d608dc62663da2c7be9e9a14dead12f3b9189afcba7e580c211483df53
|