Skip to main content

Django ORM playground — dev-only web UI for ORM queries

Project description

DORM

A Django ORM playground — a dev-only web UI to run ORM queries against your connected database.

Install

pip install dorm-plg

Setup

# settings.py
INSTALLED_APPS = [..., "django_htmx", "dorm"]
MIDDLEWARE = [..., "django_htmx.middleware.HtmxMiddleware"]
# urls.py
from django.urls import path, include
from dorm import get_url_prefix

urlpatterns = [
    ...
    path(f"{get_url_prefix()}/", include("dorm.urls", namespace="dorm")),
]

Open /__dorm__/ in your browser and start writing ORM queries.

Warning: DORM executes arbitrary Python code in your Django process. It is gated behind DEBUG=True and must never be used in production.

Settings

Setting Type Default Description
DORM_AUTH_ACCESS bool False When True, requires the user to be authenticated even in DEBUG mode
DORM_URL_NAME str "__dorm__" URL prefix where DORM is mounted (used by get_url_prefix())

Access rules

DEBUG DORM_AUTH_ACCESS Authenticated Result
False any any 404
True False / unset any 200
True True yes 200
True True no 404

Example with both settings:

# settings.py
DORM_AUTH_ACCESS = True   # require login
DORM_URL_NAME = "dorm"    # mount at /dorm/

Usage

In the playground editor, write any Django ORM expression. All models from your INSTALLED_APPS are available without importing them:

# Get all users
User.objects.all()

# Filter with related fields
Book.objects.filter(author__name="Tolkien").select_related("author")

# Aggregations
from django.db.models import Count
Author.objects.annotate(book_count=Count("books")).order_by("-book_count")

Press Ctrl+Enter or click Run to execute. Results are rendered as a table.

Development

git clone https://github.com/almamydev/DORM
cd DORM
python3.10 -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
cd sandbox && python manage.py migrate && python manage.py runserver
# Open: http://127.0.0.1:8000/__dorm__/

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

dorm_plg-0.1.2.tar.gz (14.4 kB view details)

Uploaded Source

Built Distribution

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

dorm_plg-0.1.2-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

Details for the file dorm_plg-0.1.2.tar.gz.

File metadata

  • Download URL: dorm_plg-0.1.2.tar.gz
  • Upload date:
  • Size: 14.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.13

File hashes

Hashes for dorm_plg-0.1.2.tar.gz
Algorithm Hash digest
SHA256 ee0f4f0a4a7dd5b531c580d3d8eb474e11366841f40907f10d8c1da1fc8de365
MD5 166038dcf2875813b1deeaa17815b0fa
BLAKE2b-256 f9d5b405bf2f923a34a2d87342c8bfc015ff68e5ebc6a6436016a365c5caaa37

See more details on using hashes here.

File details

Details for the file dorm_plg-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: dorm_plg-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 13.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.13

File hashes

Hashes for dorm_plg-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 fd15a795cccae1f8473e60f1fc51b2590a3d1e4465e7ad434d3a80a02a0063f9
MD5 e0419efd99431c0a9c15cb10b44bf8a6
BLAKE2b-256 fcd9fed15d4d49e001154ae115255a9b6d286427c21fadaa868d36eb6893bbdd

See more details on using hashes here.

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