A management command to list all Django REST Framework routes — like `rails routes` for Django.
Project description
drf-routes
python manage.py routes — A management command that lists all registered Django URL routes in a clean, readable table and can generate a full API reference document. DRF-aware: shows HTTP methods, serializers, permissions, filters, and more — automatically.
Like
rails routes, but for Django. With API docs.
Why
Django has no built-in way to see all your registered routes at a glance. You have to trace through urls.py files manually. drf-routes solves this with a single command — and can generate a full Markdown API reference from your existing code with zero extra annotations.
╭──────────────────────────────────────────────────────────────────────────────────────────╮
│ DRF Route Map │
├────────────────────────┬──────────────────────┬──────────────────┬─────────────────┬────┤
│ URL │ Methods │ View │ Serializer │ Name│
├────────────────────────┼──────────────────────┼──────────────────┼─────────────────┼────┤
│ /api/users/ │ GET POST │ UserViewSet │ UserSerializer │ … │
│ /api/users/{id}/ │ GET PUT PATCH DELETE │ UserViewSet │ UserSerializer │ … │
│ /api/posts/ │ GET POST │ PostViewSet │ PostSerializer │ … │
│ /api/auth/login/ │ POST │ LoginView │ — │ … │
│ /health/ │ — │ health_check │ — │ … │
╰────────────────────────┴──────────────────────┴──────────────────┴─────────────────┴────╯
Install
pip install drf-routes
For colored output (recommended):
pip install drf-routes[pretty]
Add to INSTALLED_APPS:
INSTALLED_APPS = [
...
"drf_routes",
]
Usage
# List all routes (rich table in terminal)
python manage.py routes
# Filter by app
python manage.py routes --app users
# Search by URL or view name
python manage.py routes --search login
# JSON output (pipe-friendly)
python manage.py routes --format json
# Generate a Markdown API reference (saved to api_docs.md)
python manage.py routes --format markdown
# Markdown with a custom output path
python manage.py routes --format markdown --output docs/api.md
# Generate a separate api_docs.md inside EACH app directory
python manage.py routes --format markdown --per-app
# Per-app docs, filtered to a specific app only
python manage.py routes --format markdown --per-app --app users
# Custom project name in the doc title
python manage.py routes --format markdown --project-name "My API"
# Include Django admin routes (hidden by default)
python manage.py routes --include-admin
# Disable color
python manage.py routes --no-color
Options
| Flag | Description |
|---|---|
--app <name> |
Filter by Django app name or module |
--search <term> |
Search by URL, view name, or route name (case-insensitive) |
--format table|json|markdown |
Output format (default: table) |
--output <file> |
Write output to a file (auto-defaults to api_docs.md for markdown) |
--per-app |
Generate a separate api_docs.md inside each Django app directory |
--project-name <name> |
Project name used in the markdown document title |
--include-admin |
Show Django admin routes |
--no-color |
Disable colored output |
API Documentation Output
Running --format markdown generates a full api_docs.md file with:
- Cover page — timestamp, total route count, method breakdown summary
- Table of contents — per app, per endpoint with anchor links
- Per-endpoint sections — with:
- Method badges (🟢
GET, 🔵POST, 🔴DELETE, etc.) - Path parameters table (
{id},{pk}, etc.) - Serializer class
- Permission classes
- Authentication classes
- Filter backends, search fields, ordering fields
- Pagination class
- Docstring (from the view class)
- Method badges (🟢
- Appendix — flat table of all routes
All metadata is extracted automatically from your existing views — no annotations needed.
Example endpoint section
### `/api/users/{id}/`
🔷 **DRF** | **View:** `UserDetailView` | **Module:** `users.views`
**Methods**
🟢 `GET` 🟡 `PUT` 🟠 `PATCH` 🔴 `DELETE`
**Path Parameters**
| Parameter | Type |
|-----------|--------|
| `{id}` | string |
**Details**
| Field | Value |
|-----------------|------------------------|
| URL Name | `user-detail` |
| Serializer | `UserSerializer` |
| Permissions | `IsAuthenticated` |
| Authentication | `JWTAuthentication` |
| Search Fields | `username` `email` |
What it detects
| View type | Methods | Serializer | Permissions | Filters |
|---|---|---|---|---|
DRF ViewSet / ModelViewSet |
✅ From router actions | ✅ serializer_class |
✅ | ✅ |
DRF APIView |
✅ From defined handlers | ✅ serializer_class |
✅ | ✅ |
| Django CBV | ✅ From http_method_names |
— | — | — |
| Django FBV | — | — | — | — |
JSON output
python manage.py routes --format json | jq '.[0]'
{
"url": "/api/users/",
"name": "user-list",
"view": "UserViewSet",
"module": "myapp.views",
"methods": ["GET", "POST"],
"serializer": "UserSerializer",
"app": "users",
"is_drf": true
}
Requirements
- Python ≥ 3.9
- Django ≥ 3.2
- djangorestframework ≥ 3.12
rich≥ 13.0 (optional, for colored table output)
Contributing
git clone https://github.com/shibinshibii/drf-routes
cd drf-routes
pip install -e ".[dev]"
pytest
PRs welcome. Please add tests for any new behaviour.
License
MIT
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_routes-0.1.0.tar.gz.
File metadata
- Download URL: drf_routes-0.1.0.tar.gz
- Upload date:
- Size: 22.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
afddc70e6a71868505d3f7d21fe1e8e5a94df2d7d5c4babe899a8699dbe4a80c
|
|
| MD5 |
d2a8a87daaedff2f2b17c95a6553040b
|
|
| BLAKE2b-256 |
a5e4371c340e17828cef72905480829e42fe9bc15c7bd1cc6c11dd4420e72af6
|
File details
Details for the file drf_routes-0.1.0-py3-none-any.whl.
File metadata
- Download URL: drf_routes-0.1.0-py3-none-any.whl
- Upload date:
- Size: 18.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aebcb98f3078c3c8adfc69ee4c3555ae919465cbaf43ea3efd4f8fece075a7f7
|
|
| MD5 |
829d9f7fa3f740d720ae4c7e3c712996
|
|
| BLAKE2b-256 |
f07da536b72c08cd6ab5ac58a3851dd267a0c54c894939489d09dc6a62c0c805
|