Metadata-Version: 2.4
Name: dorm-plg
Version: 0.1.1.1
Summary: Django ORM playground — dev-only web UI for ORM queries
Author-email: almamydev <almamydev10@gmail.com>
License-Expression: MIT
Project-URL: Homepage, https://github.com/almamydev/dorm
Project-URL: Repository, https://github.com/almamydev/dorm
Project-URL: Bug Tracker, https://github.com/almamydev/dorm/issues
Keywords: django,orm,playground,developer-tools,debugging
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Web Environment
Classifier: Framework :: Django
Classifier: Framework :: Django :: 4.2
Classifier: Framework :: Django :: 5.0
Classifier: Framework :: Django :: 5.1
Classifier: Framework :: Django :: 5.2
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Software Development :: Debuggers
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: Django>=4.2
Requires-Dist: django-htmx>=1.17
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: pytest-django; extra == "dev"
Requires-Dist: build; extra == "dev"
Requires-Dist: twine; extra == "dev"
Dynamic: license-file

# DORM

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

## Install

```bash
pip install dorm-plg
```

## Setup

```python
# settings.py
INSTALLED_APPS = [..., "django_htmx", "dorm"]
MIDDLEWARE = [..., "django_htmx.middleware.HtmxMiddleware"]
```

```python
# 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:

```python
# 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:

```python
# 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

```bash
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__/
```
