Skip to main content

Django admin URL introspection. Inspect, search, and understand your project's URL routing—directly from the admin.

Project description

Tests codecov PyPI version Python versions License: MIT

Dj Urls Panel

Django admin URL introspection. Inspect, search, and understand your project's URL routing—directly from the admin.

DJ Urls Panel

Docs

https://yassi.github.io/dj-urls-panel/

Features

  • URL Visualization: View all Django URL patterns in an organized, searchable interface
  • URL Testing Interface: Swagger-like interface for testing URLs with:
    • HTTP method selection (GET, POST, PUT, PATCH, DELETE, etc.)
    • Dynamic URL parameter input
    • Header specification
    • Authentication support (Bearer, Token, Basic Auth, Session)
    • Request body editor with JSON formatting
    • Live cURL command generation with copy functionality
    • Real-time response display with headers and body
  • DRF Integration: Automatic detection and visualization of Django REST Framework serializers
  • Security Features:
    • Configurable SSRF protection with default blocklist for internal IPs
    • Optional host whitelisting for production environments
    • Ability to disable testing interface entirely
  • Search & Filter: Search URLs by pattern, name, or view function
  • Namespace Support: Filter and organize URLs by namespace

Project Structure

dj-urls-panel/
├── dj_urls_panel/         # Main package
│   ├── templates/           # Django templates
│   ├── views.py             # Django views
│   └── urls.py              # URL patterns
├── example_project/         # Example Django project
├── tests/                   # Test suite
├── images/                  # Screenshots for README
└── requirements.txt         # Development dependencies

Requirements

  • Python 3.9+
  • Django 4.2+

Screenshots

Django Admin Integration

Seamlessly integrated into your Django admin interface. A new section for dj-urls-panel will appear in the same places where your models appear.

NOTE: This application does not actually introduce any model or migrations.

Admin Home

URL List View

Browse all URLs in your Django project with detailed information about patterns, views, and namespaces.

URL List

URL Detail & Testing Interface

View detailed information about each URL and test it directly from the admin interface.

URL Detail

Interactive Testing - GET Request

Test GET requests with dynamic URL parameters, headers, and authentication.

Test GET Request

Interactive Testing - PATCH Request

Test PATCH/POST/PUT requests with request body editor and see responses in real-time.

Test PATCH Request

DRF Serializer Information

Automatic detection and visualization of Django REST Framework serializers with field details.

Serializer Info

URL Metadata & Usage Examples

View URL metadata and get code examples for using URLs in your Django views.

URL Metadata

Usage Examples

Installation

1. Install the Package

pip install dj-urls-panel

2. Add to Django Settings

Add dj_urls_panel to your INSTALLED_APPS:

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'dj_urls_panel',  # Add this line
    # ... your other apps
]

3. Configure Settings (Optional)

Add custom configuration to your Django settings:

# Optional: Configure dj_urls_panel
DJ_URLS_PANEL_SETTINGS = {
    # Exclude specific URL patterns from the panel
    'EXCLUDE_URLS': [
        r'^admin/',      # Exclude admin URLs
        r'^__debug__/',  # Exclude debug toolbar
    ],

    # Use a custom URLconf instead of ROOT_URLCONF
    'URL_CONFIG': None,  # e.g., 'myproject.api_urls'

    # Enable/disable URL testing interface (recommended: False in production)
    'ENABLE_TESTING': True,

    # Whitelist hosts for URL testing (SSRF protection)
    # None = default blocklist only (blocks localhost, private IPs)
    # List = only allow specified hosts
    'ALLOWED_HOSTS': None,  # e.g., ['example.com', 'api.example.com']

    # CSS: load built-in styles and/or inject your own
    'LOAD_DEFAULT_CSS': True,
    # Static paths are relative to app's static/ dir (e.g. 'myapp/css/overrides.css'
    # for a file at myapp/static/myapp/css/overrides.css). Full URLs also accepted.
    'EXTRA_CSS': [],
}

Security Recommendations:

For production environments, we recommend:

DJ_URLS_PANEL_SETTINGS = {
    'ENABLE_TESTING': False,  # Disable testing interface
    # OR if you need testing in production:
    'ALLOWED_HOSTS': ['yourdomain.com'],  # Whitelist only your domains
}

4. Include URLs

Add the Panel URLs to your main urls.py:

from django.contrib import admin
from django.urls import path, include

urlpatterns = [
    path('admin/dj-urls-panel/', include('dj_urls_panel.urls')),  # Add this line
    path('admin/', admin.site.urls),
]

5. Run Migrations and Create Superuser

python manage.py migrate
python manage.py createsuperuser  # If you don't have an admin user

6. Access the Panel

  1. Start your Django development server:

    python manage.py runserver
    
  2. Navigate to the Django admin at http://127.0.0.1:8000/admin/

  3. Look for the "DJ URLS PANEL" section in the admin interface

License

This project is licensed under the MIT License. See the LICENSE file for details.


Development Setup

If you want to contribute to this project or set it up for local development:

Prerequisites

  • Python 3.9 or higher
  • Redis server running locally
  • Git
  • Autoconf
  • Docker

It is reccommended that you use docker since it will automate much of dev env setup

1. Clone the Repository

git clone https://github.com/yassi/dj-urls-panel.git
cd dj-urls-panel

2a. Set up dev environment using virtualenv

python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

pip install -e . # install dj-urls-panel package locally
pip intall -r requirements.txt  # install all dev requirements

# Alternatively
make install # this will also do the above in one single command

2b. Set up dev environment using docker

make docker_up  # bring up all services (redis, memached) and dev environment container
make docker_shell  # open up a shell in the docker conatiner

3. Set Up Example Project

The repository includes an example Django project for development and testing

cd example_project
python manage.py migrate
python manage.py createsuperuser

4. Populate Test Data (Optional)

Add any custom management commands for populating test data if needed.

6. Run the Development Server

python manage.py runserver

Visit http://127.0.0.1:8000/admin/ to access the Django admin with Dj Urls Panel.

7. Running Tests

The project includes a comprehensive test suite. You can run them by using make or by invoking pytest directly:

# build and install all dev dependencies and run all tests inside of docker container
make test_docker

# Test without the docker on your host machine.
# note that testing always requires a redis and memcached service to be up.
# these are mostly easily brought up using docker
make test_local

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dj_urls_panel-0.3.0.tar.gz (40.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dj_urls_panel-0.3.0-py3-none-any.whl (35.9 kB view details)

Uploaded Python 3

File details

Details for the file dj_urls_panel-0.3.0.tar.gz.

File metadata

  • Download URL: dj_urls_panel-0.3.0.tar.gz
  • Upload date:
  • Size: 40.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for dj_urls_panel-0.3.0.tar.gz
Algorithm Hash digest
SHA256 d5a940e03d1a7308c3d9d2f84fd5cc826bc520416c171f7980d2563a125c7505
MD5 9900592a6bf33d975a43855bfc2e6440
BLAKE2b-256 affc040676c9ec37e735f89ba5c26745f187717402b18bf748385b546ce6e7b7

See more details on using hashes here.

Provenance

The following attestation bundles were made for dj_urls_panel-0.3.0.tar.gz:

Publisher: python-publish.yml on yassi/dj-urls-panel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dj_urls_panel-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: dj_urls_panel-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 35.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for dj_urls_panel-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4d9fe09d765575b720d22b0e24ecfda28d68d0012195ea5bd78aadb0e282b699
MD5 aa602faab2b8624eff45e1e62438effb
BLAKE2b-256 529a65de6c506c961914e5e54ff7138cd2f61f01a43febc302a383589664afec

See more details on using hashes here.

Provenance

The following attestation bundles were made for dj_urls_panel-0.3.0-py3-none-any.whl:

Publisher: python-publish.yml on yassi/dj-urls-panel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page