Skip to main content

DORM

A browser playground for the Django ORM: run Python/ORM code against your database in notebook-style cells and see results as a table.

DORM executes arbitrary Python in your Django process. Read Access before enabling it anywhere but your laptop.

Install

pip install dorm-plg            # add [redis] for the Redis storage backend
# settings.py
INSTALLED_APPS = [..., "django_htmx", "dorm"]
MIDDLEWARE     = [..., "django_htmx.middleware.HtmxMiddleware"]

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

Open /__dorm__/. DORM has no models and needs no migrations.

Features

  • Cells: each run commits a cell and opens a new one. Running a cell re-executes every cell above it first, so variables carry over. Hover a cell to run, save or remove it.
  • Editor: Python highlighting, auto-closed quotes and brackets. Ctrl/Cmd+Enter runs, Alt/Option+↑/↓ steps through recent executions, Ctrl/Cmd+/ comments.
  • Auto-imports: all models plus Q, F, Count, Sum, Avg, Max, Min, Value, OuterRef and Subquery.
  • History: a modal with Recents and Saved tabs; copy an entry, or insert it into the focused cell.
  • Export: CSV (;) or JSON. Previews show 200 rows; when a result is truncated, you choose between the loaded rows and the full result. The full result re-runs the query, and over 1,500 rows it arrives as a .zip of 1,500-row files.

Access

Setting Default
DORM_URL_NAME "__dorm__" URL prefix
DORM_AUTH_ACCESS False Require login
DORM_PERMISSION_ACCESS False Require a permission (superusers always pass)
DORM_PERMISSION_NAME "can_access_dorm_plg" Codename (any app) or "app_label.codename"
  • DEBUG=True: open to everyone, unless you turn on the auth or permission settings.

  • DEBUG=False: every DORM URL returns 404 unless all of these hold:

    • DORM_URL_NAME is a custom value
    • DORM_AUTH_ACCESS = True
    • DORM_PERMISSION_ACCESS = True
    • the user is logged in and has the permission

    manage.py check reports dorm.W001 when a setting is missing.

DORM defines no permission itself. Create it on one of your models, usually the user model:

class User(AbstractUser):
    class Meta:
        permissions = [("can_access_dorm_plg", "Can access DORM")]

With the stock auth.User, create the same Permission in a data migration (content_type = User). Then grant it in the admin.

Storage

History, saved commands and settings are stored in a pluggable backend. The default is in-memory.

DORM_STORAGE = {
    "BACKEND": "json",                                # memory | json | redis | sql | dotted.path
    "OPTIONS": {"path": BASE_DIR / "dorm_db.json"},
    "HISTORY_LIMIT": 100,
}
Backend OPTIONS
memory —
json path
redis url="redis://localhost:6379/0", prefix="dorm:"
sql alias="default": any Django database (PostgreSQL, MySQL, SQLite). Its table is created on first use.

To write a custom backend, subclass dorm.storage.BaseStorage and implement get, set, delete, all, push, range and clear.

Development

git clone https://github.com/almamydev/DORM && cd DORM
uv sync --extra dev
uv run pytest
cd sandbox && uv run python manage.py migrate && uv run python manage.py runserver

Metadata

Release files for dorm-plg 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dorm-plg 0.2.0
File Size Uploaded
dorm_plg-0.2.0.tar.gz 36.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dorm-plg 0.2.0
File Interpreter ABI Platform
dorm_plg-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 70.1 kB

Release files / dorm_plg-0.2.0.tar.gz

Download URL dorm_plg-0.2.0.tar.gz
Size 36.5 kB
Tags Source
SHA-256 checksum
How to use checksums
1c7dc400041caa409d7b7c10af529aafd2bc1f3568942d3a9473b9945eeb1602
BLAKE2b-256 checksum
How to use checksums
d89215bc72fed5f295c1415c6550f016de99fd2a14929d7aee61f32d95cce092
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.7

Release files / dorm_plg-0.2.0-py3-none-any.whl

Download URL dorm_plg-0.2.0-py3-none-any.whl
Size 33.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fc070a423cdf0e3303120f914c6ad20a9a9b63e83fb2b20ec810d9bbf9a38741
BLAKE2b-256 checksum
How to use checksums
67819e4dd39674b0992b034dafd0b7aea75d80695013df7b379b503a8b85006a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.7

Release history Release notifications | RSS feed

0.2.1

2 release files

This release

0.2.0 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page