~/work/advanced-django-admin-nested-drag-drop-m2m-matrix-ai-test-suite.md
Case study

Advanced Django Admin: Nested Drag & Drop, M2M Matrix, AI Test Suite

Three custom Django admin interfaces for a healthcare platform that go well past where most teams would reach for a separate frontend — a self-referencing drag-and-drop tree editor, a full-model M2M matrix with row/column tooling, and an AI regression-test runner that grades LLM responses against validated expectations.

role
Design & implementation of three non-trivial admin interfaces
sector
US healthcare · internal admin tooling for non-technical staff
client
name and identifying details withheld · screens and data illustrative
stack
Django · django-nested-inline (heavily customized) · Vanilla JS · Celery · AWS (serverless)
01 / Why admin, not a separate frontend

Extend the tool you already have

The path of least resistance on projects like this is to reach for a separate frontend — React, a design system, the whole kit — the moment the admin starts to strain. That's a lot of surface area to own, and most of it repeats what Django's admin already gives you for free. Each of the interfaces below is what happened when the admin was pushed further than usual instead.

02 / Nested drag-and-drop tree editor

Self-referencing hierarchies, dragged across depth

A questions-and-answers tree for configuring an AI assistant's decision logic. Each tree is a self-referencing hierarchy: a root question branches into answers, which lead to result nodes or further questions, nested arbitrarily deep.

Built on django-nested-inline but heavily customized. Out of the box, django-nested-inline only supports drag-and-drop within the same nesting level and doesn't support self-referencing foreign keys at all. The workarounds enable dragging subtrees from any depth and dropping them onto "Add another" links at any other level, with the dragged content collapsing cleanly during the move.

Dragging a subtree across nesting levels — the usual answer is "rewrite it in React." This one keeps it inside the admin, which keeps permissions, audit, and every other framework affordance in place for free.
03 / License matrix widget

One grid instead of hundreds of pages

A single admin page for managing many-to-many relationships across an entire model. Each relationship is a checkbox in a grid. Three tools work on both rows and columns depending on cursor position: check all, uncheck all, and copy — which applies an entire row or column to another.

This replaced the need to manage hundreds of individual M2M relationships across separate admin pages. The result is a single visual interface that non-technical staff can edit directly.

04 / AI test-suite runner

Versioned config plus regression runs, inside the admin

An admin section for a versioned configuration system for an AI assistant, with exports and imports (validated), plus the ability to configure and execute regression test suites against the assistant itself. Test suites run 200+ cases asynchronously across several parallel runners. LLM responses are compared against pre-validated expected outputs, with pass/fail per case, execution time per case, and an overall statistical score for the run.

05 / Surface at a glance

What the work covered

surfacecovers
tree editor self-referencing FK · cross-level drag-and-drop · collapse-on-move
m2m matrix check / uncheck / copy — on both rows and columns · replaces N separate pages
ai config versioned admin · validated export / import
ai tests 200+ cases · parallel runners · expected-output comparison · pass / fail / score
users non-technical staff editing directly in the Django admin
06 / Tech stack

Tools

  • Django
  • django-nested-inline (customized)
  • Vanilla JS
  • Celery
  • AWS (serverless)
~/work
01 / 01 navigate · Esc close