Name | django-mtg-res JSON |
Version |
0.1.5
JSON |
| download |
home_page | None |
Summary | A Django app for logging HTTP requests and responses |
upload_time | 2025-08-08 09:20:48 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.10 |
license | None |
keywords |
django
logging
requests
http
api
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
================
django-mtg-res
================
Django MTG RES is a reusable Django app for logging HTTP requests and responses. It provides a simple way to track API calls, debug issues, and maintain audit logs of external service interactions.
Features
--------
* Log HTTP requests and responses with full metadata
* Support for different request/response formats (JSON, text, etc.)
* Flexible reference system to link logs to specific objects
* Safe error handling to prevent logging failures from breaking your app
* Admin interface for viewing and managing logs
Quick start
-----------
1. Install django-mtg-res::
pip install django-mtg-res
2. Add "django_mtg_res" to your INSTALLED_APPS setting like this::
INSTALLED_APPS = [
...
'django_mtg_res',
]
3. Run migrations to create the RequestLog model::
python manage.py migrate
4. Start using the RequestLog model in your code::
from django_mtg_res.models import RequestLog
import requests
# Make an API call
response = requests.get('https://api.example.com/data')
# Log the request and response
RequestLog.create_request_log(
url='https://api.example.com/data',
method='GET',
request=None, # No request body for GET
response=response,
ref_obj='User',
ref_id='123',
remarks='Fetching user data'
)
Usage Examples
--------------
**Basic logging:**
.. code-block:: python
from django_mtg_res.models import RequestLog
# Log a simple request
RequestLog.create_request_log(
url='https://api.service.com/endpoint',
method='POST',
request={'key': 'value'},
response={'result': 'success'},
status_code=200
)
**With reference objects:**
.. code-block:: python
# Log with reference to a specific model instance
RequestLog.create_request_log(
url='https://payment.service.com/charge',
method='POST',
request=payment_data,
response=payment_response,
ref_obj='Order',
ref_id=str(order.id),
remarks='Payment processing'
)
**Safe logging (won't raise exceptions):**
.. code-block:: python
# This will not raise exceptions even if logging fails
RequestLog.create_request_log(
url=api_url,
request=request_data,
response=response_data,
safely_create=True # Default is True
)
Admin Interface
---------------
The app includes Django admin integration. You can view and search request logs in the Django admin panel under "Request Logs".
Requirements
------------
* Python >= 3.10
* Django >= 4.0
* requests >= 2.25.0
License
-------
This project is licensed under the MIT License.
Contributing
------------
Contributions are welcome! Please feel free to submit a Pull Request.
Support
-------
If you encounter any issues or have questions, please open an issue on the project repository.
Raw data
{
"_id": null,
"home_page": null,
"name": "django-mtg-res",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": "Rio Cheung <mtg.rio.cheung@gmail.com>",
"keywords": "django, logging, requests, http, api",
"author": null,
"author_email": "Rio Cheung <mtg.rio.cheung@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/75/ec/e7bbb4af36efe47e278e2ad23248e7d7a20d5c5af16607d5bae0722732a2/django_mtg_res-0.1.5.tar.gz",
"platform": null,
"description": "================\r\ndjango-mtg-res\r\n================\r\n\r\nDjango MTG RES is a reusable Django app for logging HTTP requests and responses. It provides a simple way to track API calls, debug issues, and maintain audit logs of external service interactions.\r\n\r\nFeatures\r\n--------\r\n\r\n* Log HTTP requests and responses with full metadata\r\n* Support for different request/response formats (JSON, text, etc.)\r\n* Flexible reference system to link logs to specific objects\r\n* Safe error handling to prevent logging failures from breaking your app\r\n* Admin interface for viewing and managing logs\r\n\r\nQuick start\r\n-----------\r\n\r\n1. Install django-mtg-res::\r\n\r\n pip install django-mtg-res\r\n\r\n2. Add \"django_mtg_res\" to your INSTALLED_APPS setting like this::\r\n\r\n INSTALLED_APPS = [\r\n ...\r\n 'django_mtg_res',\r\n ]\r\n\r\n3. Run migrations to create the RequestLog model::\r\n\r\n python manage.py migrate\r\n\r\n4. Start using the RequestLog model in your code::\r\n\r\n from django_mtg_res.models import RequestLog\r\n import requests\r\n\r\n # Make an API call\r\n response = requests.get('https://api.example.com/data')\r\n \r\n # Log the request and response\r\n RequestLog.create_request_log(\r\n url='https://api.example.com/data',\r\n method='GET',\r\n request=None, # No request body for GET\r\n response=response,\r\n ref_obj='User',\r\n ref_id='123',\r\n remarks='Fetching user data'\r\n )\r\n\r\nUsage Examples\r\n--------------\r\n\r\n**Basic logging:**\r\n\r\n.. code-block:: python\r\n\r\n from django_mtg_res.models import RequestLog\r\n \r\n # Log a simple request\r\n RequestLog.create_request_log(\r\n url='https://api.service.com/endpoint',\r\n method='POST',\r\n request={'key': 'value'},\r\n response={'result': 'success'},\r\n status_code=200\r\n )\r\n\r\n**With reference objects:**\r\n\r\n.. code-block:: python\r\n\r\n # Log with reference to a specific model instance\r\n RequestLog.create_request_log(\r\n url='https://payment.service.com/charge',\r\n method='POST',\r\n request=payment_data,\r\n response=payment_response,\r\n ref_obj='Order',\r\n ref_id=str(order.id),\r\n remarks='Payment processing'\r\n )\r\n\r\n**Safe logging (won't raise exceptions):**\r\n\r\n.. code-block:: python\r\n\r\n # This will not raise exceptions even if logging fails\r\n RequestLog.create_request_log(\r\n url=api_url,\r\n request=request_data,\r\n response=response_data,\r\n safely_create=True # Default is True\r\n )\r\n\r\nAdmin Interface\r\n---------------\r\n\r\nThe app includes Django admin integration. You can view and search request logs in the Django admin panel under \"Request Logs\".\r\n\r\nRequirements\r\n------------\r\n\r\n* Python >= 3.10\r\n* Django >= 4.0\r\n* requests >= 2.25.0\r\n\r\nLicense\r\n-------\r\n\r\nThis project is licensed under the MIT License.\r\n\r\nContributing\r\n------------\r\n\r\nContributions are welcome! Please feel free to submit a Pull Request.\r\n\r\nSupport\r\n-------\r\n\r\nIf you encounter any issues or have questions, please open an issue on the project repository.\r\n",
"bugtrack_url": null,
"license": null,
"summary": "A Django app for logging HTTP requests and responses",
"version": "0.1.5",
"project_urls": {
"Changelog": "https://github.com/yourusername/django-mtg-res/blob/main/CHANGELOG.md",
"Homepage": "https://github.com/yourusername/django-mtg-res",
"Issues": "https://github.com/yourusername/django-mtg-res/issues",
"Repository": "https://github.com/yourusername/django-mtg-res"
},
"split_keywords": [
"django",
" logging",
" requests",
" http",
" api"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "4dee83eb220c1868b4e775676df880c32360e31ff47314c1b3cce2f5a981d69d",
"md5": "3cb0149f9cc0182da3eb8faddfac39fc",
"sha256": "5ff29dd1e5248b848f96a7a6b09ce4ede44b2ab6b6eecc68b835727679787eda"
},
"downloads": -1,
"filename": "django_mtg_res-0.1.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "3cb0149f9cc0182da3eb8faddfac39fc",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 10299,
"upload_time": "2025-08-08T09:20:45",
"upload_time_iso_8601": "2025-08-08T09:20:45.785905Z",
"url": "https://files.pythonhosted.org/packages/4d/ee/83eb220c1868b4e775676df880c32360e31ff47314c1b3cce2f5a981d69d/django_mtg_res-0.1.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "75ece7bbb4af36efe47e278e2ad23248e7d7a20d5c5af16607d5bae0722732a2",
"md5": "7cd7624cf9cf992bd1d761cc7b13a3fc",
"sha256": "fd47d564bc0c49c48ccd732060bb828df911d2d338d73cd3fcdb5762bb2d0ea1"
},
"downloads": -1,
"filename": "django_mtg_res-0.1.5.tar.gz",
"has_sig": false,
"md5_digest": "7cd7624cf9cf992bd1d761cc7b13a3fc",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 9986,
"upload_time": "2025-08-08T09:20:48",
"upload_time_iso_8601": "2025-08-08T09:20:48.937945Z",
"url": "https://files.pythonhosted.org/packages/75/ec/e7bbb4af36efe47e278e2ad23248e7d7a20d5c5af16607d5bae0722732a2/django_mtg_res-0.1.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-08 09:20:48",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "yourusername",
"github_project": "django-mtg-res",
"github_not_found": true,
"lcname": "django-mtg-res"
}