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.
Metadata
Release files for explain-db 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 | |
|---|---|---|---|
| explain_db-0.1.0.tar.gz | 6.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| explain_db-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 13.2 kB
Release files / explain_db-0.1.0.tar.gz
| Download URL | explain_db-0.1.0.tar.gz |
|---|---|
| Size | 6.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
331173e0f91f811555e0f85950320bc5327db981a22d94f1eba54c549285e4a6
|
|
BLAKE2b-256 checksum How to use checksums |
a4c8f90e2e0253082ae8f4c550298875dfd2c3c19fec0775907923ac0200d813
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.12
|
Release files / explain_db-0.1.0-py3-none-any.whl
| Download URL | explain_db-0.1.0-py3-none-any.whl |
|---|---|
| Size | 6.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ab17dbd52b729705ae01ed88c0d08b5116225125e2d75f72a2c92e486be5e5a5
|
|
BLAKE2b-256 checksum How to use checksums |
53c4028c90e49c25fa0663237a110d43bc070d41065d6e796cab090dc19e43b7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.12
|