How it works¶
The library has two JavaScript layers and two Python mixins.
JavaScript layers¶
core.js— the engine. OnDOMContentLoadedit readswindow.DjangoFormAlpine.resolvers, iterates over all form inputs, and for each resolver applies any matching prefixed attributes to the resolved container.admin.js— the Django Admin preset. Registers built-in resolvers for all standard admin containers intowindow.DjangoFormAlpineunless you supply your own.
Python mixins¶
Mixin |
Loads |
Use when |
|---|---|---|
|
|
Any Django form with custom resolvers |
|
|
Django Admin (built-in resolvers included) |
Both mixins inject their scripts via the standard Django media property, so no template changes are needed — Django admin already renders form media automatically.
Request lifecycle¶
Page loads — Django renders the form with its media scripts.
Scripts load (deferred) in order:
admin.js→core.js→alpine.js.DOMContentLoadedfires:admin.jsregisters its resolvers intowindow.DjangoFormAlpine.resolvers.core.jsreads those resolvers, iterates all inputs, and applies prefixed attrs to the resolved containers, setting upx-dataandx-modelon the form.
Alpine.js initialises and picks up the
x-data/x-model/x-showattributes.