A Django package to expose model metadata via API
Project description
Explain DB
A Django package that provides an API to expose Django model metadata and structure information.
Installation
Install the package via pip:
pip install explain_db
Setup
- Add
explain_dbto your Django project'sINSTALLED_APPSinsettings.py:
INSTALLED_APPS = [
# ... your other apps
'explain_db',
]
- Include the explain_db URLs in your project's main
urls.py:
from django.urls import path, include
urlpatterns = [
# ... your other URL patterns
path('api/explain/', include('explain_db.urls')),
]
Usage
The package exposes one API endpoint that returns metadata for a specified Django model:
GET /api/explain/model/<model_name>/
Example
If you have a model named User, you can get its metadata by making a GET request to:
GET /api/explain/User/
Response Format
The API returns detailed information about the model including:
- Table name and description
- Column details (name, type, description, relationships, etc.)
- Foreign key relationships
- Field constraints (nullable, blank, default values)
[
{
"table_name": "auth_user",
"table_description": "User model description",
"columns": [
{
"name": "id",
"type": "AutoField",
"description": "",
"is_relation": false,
"nullable": false,
"blank": false,
"default": null,
},
// ... more columns
]
}
]
GET /api/explain/models/all
Response Format
This endpoint returns metadata for all Django models in installed apps.
Requirements
- Django >= 3.2
- Django REST Framework >= 3.12.0
- Python >= 3.8
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License.
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 explain_db-0.1.0.tar.gz.
File metadata
- Download URL: explain_db-0.1.0.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
331173e0f91f811555e0f85950320bc5327db981a22d94f1eba54c549285e4a6
|
|
| MD5 |
22709145c820dafbe296fe06def57585
|
|
| BLAKE2b-256 |
a4c8f90e2e0253082ae8f4c550298875dfd2c3c19fec0775907923ac0200d813
|
File details
Details for the file explain_db-0.1.0-py3-none-any.whl.
File metadata
- Download URL: explain_db-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ab17dbd52b729705ae01ed88c0d08b5116225125e2d75f72a2c92e486be5e5a5
|
|
| MD5 |
80bc3a576bb26fd772a9f4f1c99ccc82
|
|
| BLAKE2b-256 |
53c4028c90e49c25fa0663237a110d43bc070d41065d6e796cab090dc19e43b7
|