Before you upgrade, read Removed below.
Upgrading from 1.x: declare what your templates read. Explicit exposure is the default in 2.0 (since rc1). An attribute a view sets on
selfinmount()or a handler, such asself.items = ..., stays on the server unless the class declares it withstate(...)(items = state(default_factory=list)), so{{ items }}renders empty, with no error. Declare each value the template reads withstate(...), or supply derived values fromget_context_data().exposure_policy = "legacy"still works in rc2 with aDeprecationWarning, and is removed before 2.0.0 final (#4171). Seedocs/website/state/explicit-exposure.mdand the 2.0 migration guide.
Added
New system check
djust.S015(Warning): a model's explicitget_*()method or@property(its own or inherited, such asAbstractUser.get_full_name) that reads a field the model lists indjust_exclude_fields. The field is hidden but the computed value is still serialized, so{{ user.get_full_name }}renders thelast_namea customUserexcluded. The check parses the members' source (self.<field>,getattr(self, "<field>"), up to threeself.<helper>hops) and calls nothing; suppress withDJUST_CONFIG = {"suppress_checks": ["S015"]}. (#3955)dj-auto-recoverhandlers work under the strict parameter policy (#4178). A recovery handler declares what it receives,def restore(self, form_values: dict[str, Any], data_attrs: dict[str, str]), and the browser sends only the dictionaries it declares (plus the container'sdj-value-*arguments) after a WebSocket or SSE reconnect, including from a container inside a LiveComponent or an embedded child view, whose recovery event reaches the page's view. The values are validated by the handler's contract under the same limits as every event argument. Strict contracts accept a new annotation for this,dict[str, T]: a JSON object with string keys whose values are checked asT. New checkdjust.V031reports a recovery handler that still reads_form_values/_data_attrs(warning under the legacy policy, error under strict), declares the new names under the legacy policy or positional-only, and names the new signature; it is reported once per handler declaration, also covers a handler a computeddj-auto-recover="{{ handler }}"may name when it reads the_names, and leaves handlers no recovery binding targets (and LiveComponent handlers) todjust.V016. See Reconnection.djust.testingpublishes live-session test helpers for explicit views (#4191). An explicit view binds to a saved server session at mount and reads it, and its user, again on every turn. So a test with a stub user, a bare consumer or a request without a saved session is refused. The helper the framework's own tests used for this was private.djust.testingnow exports helpers that send every request through the project's own stack, so a test written with them fails where production would refuse:open_live_page(url, *, user=None, client=None, **extra)does the page GET through the project's middleware, with a client that enforces CSRF, and returns aLivePage.LivePage.post_event()sends the HTTP fallback POST as the browser does: the page's tab, its CSRF token, and the last answer's render digest, so it gets patches.full=Trueasks for the whole page.await LivePage.connect()mounts the view over aWebsocketCommunicatorthrough the project'sASGI_APPLICATION, falling back to a bare consumer when none is set.await LivePage.connect_sse()mounts the view over the project's own SSE URLs and middleware, and fails with how to route them when they are not routed.- The returned
LiveSocket/LiveSSEgivesend_event()(the answer matched byref),receive(),receive_nothing()andframes. A receive timeout leaves the connection usable. live_session()andwith_live_session()give a hand-built communicator, ASGI scope or request a saved session and user, recording the backendforce_loginwould.close_live_pages()and the autouse pytest fixturedjust_live_pagesrelease what a failed test left open.
SSESessiongains_skip_close_linger: the helper's stream close skips the grace period for its own session, instead of patching a module global. See "Real sessions and transports" in the testing guide.
Changed
{% data_table %}is one implementation on both engines (#3869). Under Django's template engine the tag now renders the native table the Rust engine always drew:data_tableis a simple tag that hands the same operands toDataTableHandler(render_data_table, rows and columns converted as the Rust engine hands them, so a model row is its serialised dict and the exposure floor holds). Every feature the tag documented buttable.htmlnever drew now works under DjangoTemplates (expandabledrawsdj-click="on_table_expand",editable_columns,exportable,reorderable,column_visibility,density_toggle,group_by,copyable,importable,row_drag,editable_rows,resizable, frozen columns, virtual scroll, footer aggregations, conditional formatting ...). The markup changes: it is the native table's (no whitespace between elements,data-row-keyon rows, the handler's classes and wrappers; the parity harness measured class, attribute and text differences in all 176 variants), so CSS or tests written against the oldtable.htmlmarkup may need new selectors. The parity row fordata_tableisIDENTICAL(it differed in all 176 variants). Alazystring or astrwith__html__as a cell is text on both engines now (onlymark_safekeeps markup in a cell); a row that is not a mapping (a string,None) is omitted on both engines (under the Django enginetable.htmldrew an empty row for it); a generator or set of rows or columns is still read. The native header gained what the Django template had: a sortable<th>is keyboard-focusable (tabindex="0"), the sort-direction glyph is a decorative<span class="data-table-sort-glyph" aria-hidden="true">, and the loading skeleton hasaria-live="polite"(the Rust engine's table lacked all three). Tests inpython/djust/tests/test_data_table_single_impl_3869.py.A
Componentdrawn through itstemplatenow escapes a marked-safe value in an ordinary text slot, as its Rust instance does (#3932).Alert(text=mark_safe("<b>x</b>"))printed<b>x</b>from the Rust instance and<b>x</b>from the template path (a lazy string, or a class with no crate twin such asCheckbox), so the same value printed as markup or as text depending on which path the constructor picked. The template path now escapes a{{ }}in ordinary text whatever the value is marked as ({{ v|safe }}too), except the names a class lists in the newComponent.markup_slots:Modal(body,footer),Tooltip(content) andOffcanvas(body), which escape a plain string in their constructors (Offcanvassince this change) and documentmark_safemarkup. A{% %}tag in ordinary text is not a slot and is left as it is: a marked-safe value that{% firstof %},{% cycle %}or{% blocktranslate %}prints keeps its markup, and the once-per-class warning names the tag. To print markup from your ownComponentsubclass, add the parameter tomarkup_slotsor use aLiveComponent;LiveComponentandBoundComponentinline templates are unchanged and keep markup in a text slot. Tests inpython/djust/tests/test_component_hybrid_rawtext_and_live_templates_3913_3914.pyandpython/djust/tests/test_ui_simple_components_escaping.py. The framework's own asset markup is the exception: theAssetTagsthatComponent.asset_tags()(anddjust.assets.tags.asset_tags()) returns still prints as markup in ordinary text, so the documented{{ asset_tags }}pattern of the vendored-assets guide keeps loading its library (test inpython/djust/tests/test_assets_tags.py).LIVEVIEW_CONFIG["state_models_as_handles"]now defaults toTrue. A model, model list or QuerySet held as LiveView state is handed to the template as a floored handle for the render. A filtered rebinding ({% with q=user|default:user %}{{ q.groups.count }}) and a filtered loop operand read relations as Django does, and custom filters and tags receive the floor proxy (see #3949). State, change detection, the state backend and the client payload keep the serialized dict. Set it toFalseto restore the 1.x dict (kill-switch). A key the dict path already answers keeps it: a QuerySet whosecount/exists/first/lastthe template reads, and rows the JIT serialized with the relations the template walks (prefetched,queryset_all_row_capapplied), so the overlay adds no query. A model inside a dict held in state keeps its dict (top-level keys only). A state model whose__str__returns aSafeStringstill prints escaped on a LiveView (a related model reached by a walk,{{ u.groups.first }}, prints as Django prints it, as before). A legacy view whose QuerySet relation.all()raises a database error now raises it out of the render, as Django does, instead of logging it and rendering the rows without it. Per-sync cost (_sync_state_to_rust, median of 30, a loop reading one column, flag off → on): a QuerySet of 100 rows, explicit 12.25 → 12.86 ms, legacy 0.88 → 1.43 ms; of 1,000 rows, explicit 110.8 → 118.0 ms, legacy 3.96 → 9.07 ms (each row becomes a handle at every sync); a held list costs the same. (#3936)Behavior change: a custom filter or tag handed a LiveView state model receives the floor proxy, not a
dict(LIVEVIEW_CONFIG["state_models_as_handles"], defaultTruesince 2.0, the render-time handle overlay of the ADR-027 addendum), as onDjustTemplateBackend:- attribute access works (
value.pk,value.get_full_name(), a relation walk) and dict-style access (value["name"],.get,.items,isinstance(value, dict)) stops working; - a Django-library tag that prints its operand writes the model's text on a LiveView, as on the other entries;
- a native tag's argument (
data_table,table_cell) is still the floored dict text. Setstate_models_as_handlestoFalseto keep handing custom code the dict (kill-switch). The floor holds as before:password,DJUST_SENSITIVE_FIELDS,djust_exclude_fieldsand_-prefixed names stay unreadable, and a key whose floor cannot be built renders from its dict. Two exceptions keep thedict: a model inside a dict held in state (top-level keys only), and aQuerySetkey the template also readscount/exists/first/lastoff or whose rows' relations it walks (its JIT rows are kept, so no query is added; a custom callable handed that key or one of its rows getsdicts). The proxy's methods stay callable from Python;alters_datais enforced only in templates. The ADR's actor-entry item is moot:use_actorswas removed in 2.0. (#3949)
- attribute access works (
Wizards render the flat
<field>_choicesnames under explicit exposure (#4177).WizardMixinexposes each choice field of the current step asform_choices.<field>and as a flat name such asborough_choices. The flat names were provided only on a legacy view, so on an explicit view a template that read{{ borough_choices }}rendered nothing. They now render on every view, over the page GET, the HTTP fallback, WebSocket and SSE, with no template change, including for steps fromget_wizard_steps()and for fields a form adds in__init__. A flat name never replaces a name the context already holds (a declaredstate()field, orform_choicesitself for a field namedform), and a view's ownget_context_data()can still set one aftersuper().A
dj-auto-recovertarget is no longer forced to the legacy parameter policy (#4178). ADR-036 decision R1 is superseded: dispatch, the public parameter contract and the template binding check treat a recovery handler under its own policy, so a strict handler receivesform_values/data_attrsinstead of the 1.x_form_values/_data_attrs. A handler under the strict policy that still reads the_names is refused at runtime and reported bydjust.V031; under the legacy policy (the default until strict becomes the default) it keeps receiving the 1.x envelope.djust.V019, which warned that a strict declaration on a recovery handler was ignored, is retired, and the per-render scan of the HTML for recovery targets is gone.@live_viewfunction views use explicit exposure (#4183). The view the decorator builds no longer statesexposure_policy = "legacy": the values the decorated function returns are itsget_context_data(), and the callables it returns stay its event handlers, which may use the strict parameter policy (@event_handler(parameter_policy="strict")). Nothing changes in the decorated function. Names that start with an underscore, other callables and the request are left out of the template, as before. A returned LiveView setting (login_required,permission_required,login_url,template,template_name...) still configures the view and is applied before its access checks, so a required login or permission is enforced on the page GET and the HTTP fallback as before (the function body itself runs first, on every request); such a setting is no longer also a template name. A returnedcheck_permissions,get_objectoron_mountnow raisesImproperlyConfiguredbefore the page renders or a handler runs: djust reads these only from aLiveViewclass, so before 2.0 they were silently ignored and the page was not protected; subclassLiveView, or returnlogin_required/permission_required. A returnedview,csrf_token,DATE_FORMATorTIME_FORMATis left out of the template context, so the template reads djust's own value where 1.x rendered the function's (keeping the function's would refuse the explicit render), and a returnedexposure_policyis ignored. What a function view does on each transport is unchanged: it renders on the page GET and answers an event over the HTTP fallback POST, running the function again for every request, so nothing is kept between requests; a WebSocket or SSE mount is refused withView not found, because the class it names is built inside the request. Use aLiveViewclass for a page that keeps state or uses a socket.djust's own classes no longer state a legacy mode. The admin change list and change form (
ModelListView,ModelDetailView, andModelCreateViewbuilt on it) and the ttyd terminal base classTtydTerminalViewuse explicit exposure, and the componentMeta.eventview-level alias (toggle_dropdown,toggle_modal,set_tab...) is no longer pinned to the legacy parameter policy: it follows the project's policy. Their pages and frames over WebSocket, SSE and the HTTP fallback are the same as before. Under a project-wide strict policy the alias now compiles as a strict handler: itscomponent_idis a framework-supplied argument, bound only when it is empty or names a component the view class declares (the rule the transports already apply before an event reaches the alias), and the page publishes the alias's strict contract (value,**kwargs), so the client sends itdj-value-*arguments, notdata-*. Developer-visible differences: aTtydTerminalViewsubclass whose template reads its own attributes (session_log,terminal_connected) lists them inget_context_data()built onsuper(), or they render empty (djust.T027names each); an adminchange_list_widgets/change_form_widgetsview that still statesexposure_policy = "legacy"makes the admin page fail to render (migrate the widget; the new Error-level checkdjust.V032names the admin slot and the widget, and the page'sExposureErrornames the widget class); the alias's published handler metadata readsparameter_policy: nullinstead of"legacy". The T027 hint and the unsupplied-name log no longer suggestexposure_policy = "legacy". (#4185)The framework's own components pass event arguments as
dj-value-*, notdata-*(#4186). A strict event handler (event_parameter_policy = "strict", which #4189 makes the default) receives onlydj-value-*arguments, so the arguments djust's component tags and templates sent asdata-*never reached one. Every such argument is now adj-value-*: the component tags, the nativedata_tableand its Python template (and the argumentsdata-table.jsanddata-grid.jsfill in before a click), the pagination and toast templates, the theming dropdown, modal, nav group and tabs, the table and tabs components, and thedjust newscaffold. A legacy handler receives the same arguments as before, because the client collectsdj-value-*under both policies:<!-- 1.3 --> <th dj-click="on_table_sort" data-value="name"> <!-- 2.0 --> <th dj-click="on_table_sort" dj-value-value="name">If your CSS, JavaScript or tests select a framework element by one of those attributes, select the
dj-value-*instead: for example[data-value="b"]on a combobox option is now[dj-value-value="b"].data-*attributes that are not arguments (data-component-id,data-fieldon a form field,data-open,data-row-key, and the other markers listed inpython/djust/tests/test_framework_dj_value_4186.py) are unchanged.- The
data_tablefilter and expression inputs now send their column. They carried it asdata-column, which an input event never collects under either policy, soon_table_filterreceived no column from a browser and ignored every column filter, andon_table_expressionignored every expression.on_table_expressiontakes the column ascolumn(the old{column, expression}JSON invaluestill works), andon_table_filterno longer reads adata-columnkey out of**kwargs. - The file tree sends
nameandtypeasdj-value-*; its rows keepdata-name, which theFileTreehook reads. - A clickable
data_tablerow also sends its key asrow_key(dj-value-row-key), which differs fromvaluewhenrow_click_value_keyis not the row key; a data card grid card sends itscategory. A legacy handler received both before, fromdata-row-keyanddata-category, which stay as markers. - Markers that repeat the event's
value(data-dateon a calendar day,data-densityon a density button,data-theme-modeon a theme toggle,data-col-keyon a sortable header) staydata-*, so a strict handler does not receive them: under strict, readvalue.
- The
The demo project runs on explicit exposure and strict event parameters (#4187). No demo view states the legacy exposure policy any more, and
manage.py checkwithevent_parameter_policy = "strict"reports no V016, T019, T020 or V029 on the demo apps. Each page declares its state withstate()(persist="server"where a handler changes it), builds its presentation components inget_context_data(), types its handler parameters and passes event arguments asdj-value-*instead ofdata-*. The rentals pages compute their lists from declared filter inputs on every render, and read their rows on every render or keep a row's id rather than the row, because the HTTP fallback restores a saved model instance as its field dict (examples/demo_project/djust_rentals/views/_rows.py). The performance demo keeps its item list in private attributesmount()creates, not apersist="server"field, which a thousand items outgrow. The tenant demo reads its tenant from the path (/demos/tenant/<tenant_id>/): the SSE event request carries the mounted path but not its query string, so a?tenant=tenant was the default on SSE events and they were refused.tests/integration/test_demo_explicit_4187.pydrives each migrated page's main interaction over the WebSocket, SSE and the HTTP fallback, then reconnects and checks the declared state.- Removed from the demo: the legacy twin of the exposure matrix
(
/demos/exposure-legacy/), the strict-parameters page's legacy handler, and the two React demo pages (djust.reactitself is #4006). The exposure-matrix playwright script now runs the explicit view only; underDEBUGits own error frame is the harness control, and in either mode the failing handler'sE5_LOG_CONTROLline must be in the server log before a "not in the log" check counts. - The demo's own tests (
djust_rentals/testsand its component tests) now run in CI'sdemo-checksjob, and locally withmake demo-tests. Nothing ran them before, so the demo'sStatusBadge, which put its icon into the markup unescaped, failed its own escaping test unnoticed; it now escapes the icon withformat_html. No demo page passed an icon from user input. The shared demo UI components (examples/demo_project/djust_shared/components/ui.py) render withformat_htmltoo: a value documented as HTML (Card.content,Section.content,Button.icon_svg,Button.extra_attrs) is markup only when the caller marks it safe.
- Removed from the demo: the legacy twin of the exposure matrix
(
Startup (
ready()) now raisesImproperlyConfiguredwhenQuerySet._fetch_allor Django's /functools'cached_property.__get__, which held-row refresh (#4112) wraps to note which view filled a value, has a different signature on the installed Django, instead of recording nothing and keeping stale rows. TheQuerySet._fetch_allwrapper stays: the checkpoint alternative costs one refresh-everything on each view's first write. (#4210)djust admin:
ModelDetailView.save()takes the submitted form, notredirect.save,save_and_continueandsave_and_add_anothernow receive the change form's values (**form_values) and save those; a call that carries none of the form's fields saves nothing and shows "nothing was saved". A subclass that overridessave(self, redirect=...), or callsself.save(redirect=False), now fails that way instead of saving: usesave_and_continue(**form_values)for the save that stays on the page, or call it with the values to save. (#4218)
Fixed
On an explicit view (the default policy), a loop row's relation walk over a QuerySet or model list supplied by
get_context_data()now renders what Django renders:{% for u in users %}{{ u.groups.count }}/{% for g in u.groups.all %}/{{ u.groups }}/{{ users.0.groups.all.0.name }}and a reverse accessor (g.user_set.all) rendered empty. The native render now keeps the evaluated rows (never the QuerySet, so{{ users.query }}stays unreachable) for a name whose rows the template walks past their columns, floored like every sidecar value, with no extra query for the outer QuerySet. Those names also go through the template-aware JIT on an explicit view, as on legacy, so a loop over a filtered operand (users|slice:':2',dictsort,{% with first=users|first %}), a QuerySet nested in a dict or a list of dicts, and the configured row cap render what legacy renders. (#4069)A diff render (
render_with_diff, every event) no longer replays a stale loop item whose body read through a live object: a loop row's relation ({% for u in users %}{{ u.groups.count }}), a row a relation walk returned ({% for p in u.user_permissions.all %}{{ p.codename }}), or a state model handle ({% for x in us %}{{ x.email }}withstate_models_as_handleson). The loop render cache keyed such an item by its loop binding only (a model handle hashes as its__str__), so a changed relation or field kept the first render's text. An item that reads through the render sidecar or an object handle is now rendered every time and never cached. (#4069)A component built without an explicit
component_idduring a render of a view (for example a navbar built inget_context_data) now gets the same default id on every render, derived from the view's class, the component's class and its position in that render, so a page that uses one can get HTTP fallback patches instead of the whole page. Two components of one class in one render keep different ids. A component built inmount()of a root view gets the same kind of id (never equal to a render-built one); one built in an event handler,handle_params, anasync defmount or an embedded child's mount keeps its random id. The id includes the child'sview_id, so two children of one class on a page do not share ids, and it is never an id the view still holds from an earlier render (a lazily built component keeps a random one). (#4114)With
LIVEVIEW_CONFIG["worker_threads"]on, a tick and adb_notifyturn now run as one hop on the session's thread for both exposure policies, as the server-push turn does since #4152: the stale-connection check, an explicit view's authorization, the hook and the render share the hop; an explicit view's state is saved before the frame and a failed save withholds the frame. Adb_notifymessage no longer takes Channels' separate connection-check hop. A view with anasync defhandle_info,handle_tickorcheck_permissionskeeps the previous path. (#4166)A
{% live_render ... lazy=True %}child now handles events over the WebSocket and SSE (#4167). Only the page GET filled lazy slots, so the socket's view never held the child and its events answered "Embedded view not found"; each socket re-render also queued another fill nothing ran. On a live connection the child is now mounted, authorized and registered like a child withoutlazy=(a refused one showsLazy child <id> failed.); the page GET still defers it.A handler's session-only write (including an in-place change) is now stored over WebSocket and SSE for legacy-exposure views, for
handle_tick, server-push handlers andhandle_infoturns that render nothing (both policies), and forhandle_paramsonurl_change. Legacy saves are merged with other requests' writes and best-effort (a failed save is logged; the frame still goes); a legacy socket mount reads the session once to track it. Changes made throughsession.items()/.values()are still not seen: assign the key. (#4168)SSE reconnect keeps what the user had typed for form recovery and
dj-auto-recover(#4178). The SSE reconnect mount replaced the page's markup with the server's defaults before recovery read it, so form recovery replayed nothing and adj-auto-recoverhandler received the empty form. The SSE mount now saves the values before the mount and puts them back afterwards, as the WebSocket mount does.A
cached_propertyfilled in a thread that does not carry the step's context (a plainthreading.Threada handler started) now makes the view's read set unknown, so a later write to the table it read refreshes the view instead of answering with the old rows. Provenance is the context that filled the property, not when it ran; a thread that carries the context (sync_to_async,copy_context().run) stays recorded. (#4210)Background work cancelled by a disconnect keeps nothing: once the connection's teardown has cancelled
start_async()/@backgroundwork, its result stores no session write, no view state and sends no frame, on the WebSocket and SSE alike. Previously a result whose cancellation did not interrupt it could still store the work's session writes after the teardown (when the work failed, or itshandle_async_resultraised). (#4211)A project made with
djust newdid not serve the SSE transport (#4216). Its URLconf routed the page but not djust's SSE views, so a client that fell back to SSE got a 404 at/djust/sse/<id>/. Every scaffold,--bareand--from-schemaincluded, now routespath("djust/", include(sse_urlpatterns)), so a fresh project serves a view over WebSocket, SSE and the HTTP fallback. An existing project adds that line to its root URLconf. New cases inpython/djust/tests/test_scaffold_sse_4216.pygenerate each kind of project, run itsmanage.py check, mount its index view over SSE and send one event over that session. The SSE guide's nginx example hashed$request_uri, which sends a session's stream GET and itsmessage/POSTs to different processes; it now hashes the session id.python/djust/components/tests/ran in no CI job (#4217). It sat under no pytest root, and CI passes its three roots explicitly (which overridestestpaths), so its 153 tests never ran. The directory moved topython/djust/tests/components/, where every job, the shard splitter and the test selector already look; all 153 pass there. The retro-marker tests (4, also never collected) moved totests/test_retro_markers.py.testpathsnow equals the CI roots (tests,python/tests,python/djust/tests), so a barepytestruns what CI runs, andtests/test_ci_python_test_roots.pyfails on any tracked test-shaped file outside those roots that is not listed with a reason.Admin change form: typing in a field was refused, and Save reported success without saving it.
AdminFormMixin.validate_fieldoverrodeFormMixin.validate_fieldwithout@event_handler, so on the explicit-exposure admin views every keystroke was refused; Save then saved the stored values and showed "Changes saved successfully".validate_fieldis now a declared handler with strict parameters (field: str,value: Any), and the admin's field widgets bind it by name alone (dj-input="validate_field"/dj-change="validate_field"), so the client sends the field's name and value (a checkbox's checked state, a multiple select's list) instead of the junk positional tokens'value'/'this.checked'the adapters used to emit. The change form is now one<form dj-submit="save">: every Save button submits the values on the page, so what is saved is what the person sees, whether or not each field's live event arrived, and an unchecked checkbox savesFalseas in a native post. A Save that carries none of the form's values saves nothing and says so on the page ("nothing was saved"), never "saved".save,save_and_continueandsave_and_add_anothertake the submitted values (**form_values) with strict parameters whatever the project's policy, so the pressed button arrives as its ownname=valueon the WebSocket, SSE and the HTTP fallback alike;save()no longer takesredirect(save_and_continueis the save that stays on the page). After Save and Save-and-add-another the page navigates withlive_redirecton every transport; the template's inline redirect<script>read aredirect_urlthe page context never held, so it never ran. (#4218)"Save and continue editing" on an add page goes to the new row's change page, as in Django; it used to stay on the add page, so over the HTTP fallback (which builds the page afresh) the next Save added the row again. The change form is Django's admin form: only the fields the ModelAdmin shows (
fieldsets/fields) that its form declares, lessreadonly_fieldsandexclude, are form fields. A readonly field is shown as text read from the row and is not bound or saved, so a Save no longer writes the value the page was loaded with over a change made since, and an add page whose readonly field is required on the model can be saved. An excluded field, or one a customModelAdmin.formdeclares but the admin does not show, is not on the page and a forged frame cannot write it. A nullable boolean (BooleanField(null=True)) is Django's three-way select (Unknown / Yes / No): as a checkbox, a Save that did not touch it stored None over a stored True. A choice field drawn withRadioSelectrenders one radio per choice with the stored value checked (it rendered one unchecked required radio, which kept the form from submitting). A number input carries the constraints Django's widget gives it (aDecimalField'sstep, so "1.5" is not refused;min,max,maxlength), and a stored zero is shown as0rather than emptied.Admin widgets were mounted again on every parent event and lost their state.
_change_form_widgets.htmland_change_list_widgets.htmlembedded eachchange_form_widgets/change_list_widgetsview with{% live_render %}and noview_id, so over the WebSocket and SSE every re-render of the page mounted the widget again under a newchild_Nid:mount()ran again, itsstate()restarted, and an event sent to the old id got "Embedded view not found". Each widget slot now passes a stableview_id(djust_admin_widget_1,_2, ... in list order), so the explicit child is reused while its inputs are unchanged andmount()runs once. The HTTP fallback renders the same id on the page GET and on every POST (it waschild_1on the GET and a new number on each POST). Other{% live_render %}uses are unchanged: the framework's id assignment is untouched. (#4223)djust.T027no longer counts a local dict's keys as supplied context (#4224). Following a view'sget_context_data()throughsuper()(#4185), the check counted anyname["key"] = ...in an override as supplyingkey, including writes to an unrelated local dict and assignments inside a nested helper function, so it stayed quiet about names nothing supplies. A key now counts only when it is written into the dict the override returns (a returned literal, or a local bound tosuper().get_context_data(...)or a literal that is returned or spread into the returned literal,return {**ctx, ...}), and nested functions are not read. Shipped example: a subclass of the admin change list (ModelListView) whose template reads its ownchoicesattribute is warned again; the change list wrotefilter_data["choices"]on a per-filter dict. Over the demo project the check's output is unchanged (no warnings before or after); across every djust and demo class onlyModelListView's supplied set changed (it lostchoices).Directives the server runs on the page's view follow the page view's strict handler contract inside a component or an embedded child (#4225).
dj-viewport-top/dj-viewport-bottom,dj-mutation,dj-copy-event,dj-dialog-close-eventand the JS-commandpushsend no component or child id, so the server runs them on the page's view wherever the element sits. The browser looked the handler up under the nearest component or{% live_render %}child instead (dj-viewport,push), or did not apply the strict contract at all (dj-mutation,dj-copy-event,dj-dialog-close-event), and sent the 1.x payload a strict page handler refuses. Each now resolves the page view's contract, asdj-auto-recoverdoes since #4178: a strict handler receives the generated values it declares (edge;mutation,attrs,added,removed;text) plus the element'sdj-value-*arguments, over WebSocket, SSE and the HTTP fallback. A legacy or unlisted handler keeps its payload unchanged, and a binding that carries owner context (dj-clickin a component) still uses the component's or child's contract. The binding check (djust.T020) now modelsdj-mutation's payload as the client sends it:mutationandattrswhendj-mutation-attrnames an attribute,mutation,addedandremovedotherwise. It listed onlymutation, so a legacy handler that does not accept the other names, which the server refuses, was not reported; a strict handler that requires a name its element never sends is now reported. A test reads the generated names from the client source for every directive above, so the server's list and the client's stay the same.stream_to,stream_text,stream_startand the other stream operations now reach SSE clients (#4232). They returned early unless a WebSocket consumer was attached, so a view served over the SSE transport logged "no WebSocket consumer attached" and the client received nothing. Stream operations now go out over the live transport, WebSocket or SSE, and an SSE client sees the same frames as a WebSocket one, including for views mounted in a slot. The HTTP fallback has no push channel, so stream operations remain a no-op there. 2 regression tests intests/integration/test_stream_sse_parity_4232.py.The datatable demo's "Add sample products", "Clear" and "Toggle inactive" buttons work again (#4234). Their click handlers were lost when the demo was ported to
djust_demos, so every click was rejected with "Event rejected".ProductDataTableViewnow definesadd_sample_products,clear_productsandtoggle_inactive, keeps the rows between clicks, and pushes the updated products and stats to the table. 3 regression tests intests/unit/test_datatable_demo_buttons_4234.py.@live_viewfunction views no longer open a socket they cannot mount (#4236). The page's root now carriesdata-djust-transport="http", so the client sends events over the HTTP fallback directly instead of opening a WebSocket (and then SSE) whose mount is refused withView not found, and the console no longer blamesLIVEVIEW_ALLOWED_MODULES. That warning is also no longer shown onuse_websocket: Falsepages, and a TurboNav load now honoursuse_websocket: False.{{ qs.count }}and{{ qs.exists }}on a QuerySet render their value on the native renderer instead of an empty string (#4241). This covers a QuerySet in the context of aLiveView, with explicit or legacy exposure, and{% if qs.exists %}. The value is answered from the rows already fetched for the page, so reading either costs no more queries than{{ qs|length }}, and the sidecar still hides fields such aspasswordand refuses methods likedelete. 8 regression tests inpython/tests/test_queryset_count_exists_4241.py.djust initnow tells you when the project does not route djust's SSE transport (#4242). The URLconf (ROOT_URLCONF) was never looked at, so an initialised project whose client fell back to SSE got a 404 on the stream with no hint why.initstill does not editurls.py; whendjust.sse.sse_urlpatternsis not routed it reports the step as skipped and prints the import andpath("djust/", include(sse_urlpatterns))line to add, in the dry run too. A routed project stays quiet and the exit code is unchanged. 4 regression tests inpython/djust/tests/test_djust_init_sse_4242.py.The admin change form shows
readonly_fieldsentries that name aModelAdminmethod, a model attribute or a callable (#4244). Such entries were silently dropped from the page, and a method name also listed inModelAdmin.fieldsmade the change page fail with a 500. They now render as Django's admin does: label fromshort_descriptionor@admin.display, value HTML-escaped,Yes/Nofor boolean displays, and-on the add page without calling the method. 6 regression cases inpython/djust/tests/test_admin_readonly_callable_4244.py.The pre-push hook no longer attempts a whole-suite run when test selection falls back (#4253). When
scripts/select-tests.pyansweredFULL, printed no selection or could not run, the hook ran every test root, which the local load guard refuses without the developer's approval, so such a push could never pass. It now runs the bounded early tier plus the files the targeted selection names, and says that CI runs the rest;DJUST_PREPUSH_FULL=1still forces every root, under the guard's approval. A.test_durationschange no longer forcesFULL: the tests that read it are selected. 5 regression tests intests/unit/test_prepush_bounded_fallback_4253.py.push_state()andflush_push_events()now reach SSE clients (#4256). Both returned early unless a WebSocket consumer was attached, so over the SSE transportpush_state()logged "no WebSocket consumer attached" and sent nothing, and events flushed mid-task in a@backgroundhandler (includingTutorialMixinsteps) arrived only when the task ended. Both now go out over the live transport, WebSocket or SSE; an SSEpush_state()frame carries the version SSE clients expect, and each flushed event is sent once. On the HTTP fallbackpush_state()is still a no-op, and queued events still ride the response to the request. 3 regression tests intests/integration/test_push_sse_parity_4256.py.A loop row field named
count,exists,firstorlastno longer makes the context QuerySet readable on the native renderer (#4258). The #4241 change kept a QuerySet for the render sidecar when the template read one of those names anywhere under it, and a loop row's field ({% for o in qs %}{{ o.first }}{% endfor %}) counted as a read ofqs, so{{ qs.query }}in the same template rendered the SQL. The QuerySet is now kept only when the template reads the method on the QuerySet's own name, directly or through a{% with %}alias or a filter argument. 7 regression tests inpython/tests/test_queryset_method_binding_4258.py.Pull-request CI's test selection always includes the test files with a strict xfail (#4259). A fix can make a strict
xfailpass, which fails the test, through code the test file never imports or names, so the selection missed it and the failure surfaced only in the merge queue.scripts/select-tests.py --cinow adds every file withxfail(..., strict=True)to a selection; they do not turn an empty selection into a run, and do not change aFULLanswer. 2 new tests intests/unit/test_select_tests.py.A mount the socket refuses because
SESSION_ENGINEcannot holdpersist="server"state now logs the reason (the engine found and the supported ones) behind "Protected view operation failed", as the GET, the HTTP fallback and the SSE route already did; it was value-free only. The same applies to any framework configuration error (ExposureConfigurationError) caught byhandle_exception. (#4262)A loop sorted by a method key on an explicit view renders as Django does, and
{% regroup ... by <method> %}calls the method on a legacy view too.{% for u in users|dictsort:'get_username' %}(alsodictsortreversed, a{% with %}alias, or a variable naming a method or a dotted path) now renders the empty loop Django renders; before, an explicit view sorted the rows by the called value. With JIT serialization on, such a name takes the JIT as it does on a legacy view; a variable naming a column or a property stays on the normalized rows and sorts as before. A{% regroup users by get_username as g %}on a legacy view grouped everything underNone; it now groups by the called value. (Known and unchanged: a method key the template also prints,dictsort:'get_username'beside{{ u.get_username }}, still sorts where Django renders empty; and adictsortand a{% regroup %}by the same method key on one root group underNone.) (#4264)A component's
template_namefile can{% include %}a template by a relative./or../name (#4265). ALiveComponentor descriptor (BoundComponent)template_namefile without{% extends %}failed with a "Template not found" error on{% include "./part.html" %}(the same name worked in a file with{% extends %}and in Django's own engine). The file's own name is now given to the engine, so the name resolves against the file. The "not scanned" hybrid-attribute warning also read such a name by its raw text, which the loader joins to the template root, so it counted the wrong file (a slot-holding target went unreported; a slot-free relative{% extends %}target was reported); it now resolves the name against the file, and counts a relative name in an inlinetemplate(which has no file to be relative to). Tests inpython/djust/tests/test_component_hybrid_rawtext_and_live_templates_3913_3914.py(TestRelativeNamesInATemplateNameFile,TestRelativeIncludeNamesInTheWarning).An embedded
{% live_render %}child whosetemplate_namefile includes a partial by a relative name keeps that partial'sdj-modelfields and re-renders (#4265). The allowlist walker and the child's re-render (render_embedded_child_html) both read the file's source with no template name, so{% include "./part.html" %}did not resolve: the partial's fields were silently refused and the firstdj-modelupdate that re-rendered the child failed. Both now name the include against the child'stemplate_name. Tests inpython/djust/tests/test_live_render_relative_include_allowlist_4265.py.A LiveView
template_namefile can{% extends %}and{% include %}by relative.//../names, at every level of the chain (#4265). The Rust inheritance resolver (resolve_template_inheritance, behind a LiveView'sget_template(), an embedded{% live_render %}child, JIT extraction andruntime.template_source) was started with no name for the child, so{% extends "./base.html" %}searched the template roots and raised "Template not found". It now resolves each relative name against the file that holds it, as Django does (including refusing a name that leaves the template root), and a flattened parent's{% include "./q.html" %}is named against the parent's directory. Tests inpython/djust/tests/test_liveview_relative_extends_4265.pyand theinheritancemodule ofdjust_templates.Admin delete page: deleting over the HTTP fallback failed with a server error, and no transport left the page.
ModelDeleteViewusedself.object, which over the HTTP fallback is the view's restored state rather than a model instance: the delete raised'dict' object has no attribute 'delete', and ahas_delete_permission(request, obj)that reads the row could not.ModelDeleteView.get_object()now loads the row by its key through the ModelAdmin's queryset, so the per-event object permission and the delete both get the row on every transport. After deleting, the page navigates to the change list withlive_redirecton the WebSocket, SSE and the HTTP fallback alike; the template's inline redirect<script>never ran after a re-render. (#4218)
Security
- A Component's hybrid template judges a URL whose character reference is completed by the slot (#3923).
href="
{{ s }}"with6;avascript:..., orhref="javascript&{{ s }}"withcolon;..., printed a value the browser reads asjavascript:: each literal was decoded before the slot's text was joined to it, and a literal ending in&counted as fixing the value. The value is now decoded as it is printed (the literal text and the slot's escaped text together) before the scheme check, a literal ending in an unfinished character reference no longer fixes the value, and a dotted or filtered slot after one is listed in the warning as escaped but not judged. Text a block or a printing tag ({% now %},{% cycle %}) may print before a literal is part of that value too:{% if x %}&{% endif %}#{{ s }}no longer counts the#as fixing it, in a value of a shape the paths are not followed for (a{% now %}, more than 64 paths) as in one they are. Regression tests inpython/djust/tests/test_hybrid_attrs_charref_join_3923.py. - More URL shapes of a Component's hybrid template are judged (#3924). A URL value with more than 64 paths (seven independent
{% if %}blocks before the slot), or a{% now %}before the slot, was escaped but printed as given, sojavascript:got through with a warning; such a value whose slots are plain names is now judged slot by slot and fails closed. Identical paths count once, so most values stay under the cap and are judged exactly. Each value of a{% cycle %}of literals is judged as a branch, and{% cycle ... as c %}, which prints, no longer hides its text from the check ({% cycle 'javascript' 'x' as c %}{{ s }}printedjavascript:with no warning). A dotted, filtered, loop orwithslot, and a slot after{% firstof %}or a{% cycle %}of variables, stay escaped and named by the warning, by decision. Regression tests inpython/djust/tests/test_hybrid_attrs_unjudged_shapes_3924.py. - A
LiveComponent/BoundComponenttemplate_namefile's own source now follows the attribute and raw-text escaping rule (#3933). Only an inlinetemplatewas read byharden_context; a file went torender_to_stringor the LiveView engine entry as written, so<a href="{{ url }}">with a state valuejavascript:alert(1), or a marked-safe value intitle="{{ v }}"/<textarea>{{ v }}</textarea>, printed unescaped there. Both classes now draw the file through one helper (_render_template_file): the file's own attribute slots are escaped whatever the value is marked as, a URL is checked against the scheme allowlist, and<textarea>/<title>/ comment text is escaped. A text slot keeps its markup. Content the file gets from{% extends %}(the parent's slots) or{% include %}is not scanned and is named by the same once-per-class warning as for an inline template. A file whose source the backend does not expose is drawn as before and named once. A function component's file (@component(template_name=...)) and the suspense fallback are unchanged. The dj-if ids of a file with attribute slots change once on upgrade (they hash the rewritten source). Tests inpython/djust/tests/test_component_hybrid_rawtext_and_live_templates_3913_3914.py(TestTemplateNameFile). - A dict from user data that carries
__str__,__model__andpk(a stored JSON column, an API payload) is no longer read as a serialized model bypprint,json_script,.items/.keys/.values, iteration,in,pluralizeorstringformat. The model marker is now the TYPE of the__model__value:serialization.model_identitystamps aModelName(astrsubclass; the JSON the client receives is byte-identical), the Rust engine reads it as its own value kind, and only that makes a map a model. The binary state encoding carries the marker under a new tag, and a user map shaped like that tag is escaped, so data cannot mint it through a state round trip.serialization.is_serialized_model_mapchecks the same type. State written by an earlier build reads its model maps as dicts until the next sync restamps them. (#3947) - Marked-safe values are escaped in the attributes of the admin, allauth / djust_auth, bug-capture replay and gallery templates (#4157). Django's autoescape leaves a value marked safe as it is, so a value marked safe for text could close an attribute of these pages and add another. Every attribute slot of the
djust_admin,allauth/elements,djust_auth,templates/djust/bug_capture/replay.html,djust_components/galleryanddjust_theming/gallerytemplates now uses|force_escape, and a URL attribute (href,action,src,formaction) goes through the newdjust_url_attrfilter ({% load djust_attrs %}), which escapes once and turns ajavascript:/vbscript:/data:URL into#(thedata_url_attrrule). A quoted string argument of adj-click/dj-changehandler (the admin list'ssort_by(...)/apply_filter(...)) goes through the newdjust_handler_argfilter, which backslash-escapes\ ' "for the client's argument parser before escaping HTML:force_escapealone is decoded by the browser first, so a'in a name ended the argument string. Its filters bridge to the Rust engine on{% load %}, so a child template that extends another can use it. The #4009 sweep now covers these templates twice: a static pass over every{{ }}in a start tag, and a render of each page with every value the marked-safe payload (Django, and the Rust engine for the LiveView admin pages); both find nothing. Regression tests inpython/tests/test_marked_safe_attribute_sweep_4009.py(TestEveryPageTemplate). - The HTTP API and
@server_functionendpoints answer aPermissionDeniedwith the fixed message "Permission denied" (#4170). The exception's text no longer reaches the caller on any view, under any policy, DEBUG included; it goes to the server log only. This matches WebSocket and SSE, which always answerPermissionDeniedwith a fixed "Permission denied"; other error detail still follows ADR-038 D-a (revised): detailed under DEBUG, value-free in production. A test now pins every HTTP response body (JsonResponse,HttpResponse*,StreamingHttpResponse, the API error envelope) and client frame that interpolates an exception, package-wide, including a one-step flow through a local name; a new site fails until it is fixed or classified with its reason. - The safe-markup guard closes the follow-ups of #3864's second review (#4212). A slice or a
strip/replaceof a URL checker's output (safe_url(x)[1:]) reads as escaped text, not as a checked URL, so it is refused at the start of a URL.format_html/format_html_joinarguments are placed for a format string held in a name, a parameter default or a branch, and after*args/**kwargs(a format string the guard cannot read, with arguments, is reported). An HTML-escaped value or a URL checker's output (safe_url,url_attr) in astyleattribute is reported (CSS:safe_css_*is the rule there; a relative URLsafe_urlaccepts can hold)and;): the guard reads a checked URL and a CSS escaper's output as two classes, each fitting its own attribute value. A nested format spec has a behavioural row, three call-binding mechanisms no verdict depended on are removed, a test pins that the audit's findings do not depend on which files are scanned together, and CI'ssecurity-testsjob installs jsdom and runs the browser-oracle rows withDJUST_REQUIRE_BROWSER_ORACLE=1, where a missing oracle fails instead of skipping. Rows inpython/tests/test_safe_markup_position_3864.py. - SSE events no longer lose the page's query string during authorization (#4231). An explicit view that resolves state from the query (for example a
TenantMixinview reading?tenant=) resolved a different tenant on an SSE event than it did at mount, so the identity binding no longer matched and the first event was refused with "Event authorization failed". The event request now takes the query from the trusted mount request, as the WebSocket and HTTP fallback already did; the query on the SSE message POST itself is still ignored, and a changed tenant is still refused. 6 regression tests inpython/djust/tests/test_sse_event_query_string_4231.py. - With
reauth_on_event, the SSE per-event auth re-check sees the page's route, as the WebSocket and HTTP fallback do (#4255). On a legacy-exposure view withlogin_requiredorpermission_required, the SSE re-check ran against the raw/djust/sse/<id>/message/POST, so acheck_permissionsthat readsrequest.pathorrequest.GETwas shown a different path and query than at mount and could decide the event differently from the other transports. The re-check now keeps the live POST's user and session and takes the path, resolver match, slot and page query from the mount request; an SSE navigation or slot mount turn uses the destination page's request. The query on the message POST itself never counts, and a principal revoked mid-session is still denied. 8 regression tests inpython/djust/tests/test_sse_reauth_mount_request_4255.py.
Documentation
The website examples are explicit and strict, and the doc-snippet test runs them that way (#4188). Every example in
docs/websiteuses the 2.0 spellings: explicit exposure, typed handler parameters without a**kwargsthat only absorbed what the browser sent, and event arguments passed asdj-value-*instead ofdata-*.exposure_policy = "legacy"appears only in the migration guide, as the thing being replaced, and in checkV028, which reports it. Pages that changed what they teach:- Events teaches the strict rules (the signature is the contract; the
browser sends
value,field, form fields and keys only to a handler that declares them),fieldin place of_target, and a new "Event arguments (dj-value-*)" section with the strict wire hints (:int,:float,:bool,:list,:json).data-*attributes are not arguments. - Explicit exposure no longer offers the legacy policy as a way to keep a view working; "Migrating a view" points at the migration guide, which now carries the 2.0 pre-release stopgap.
- Best practices: a service client kept as a plain attribute is fine under explicit exposure (only declared, persisted state must be JSON); defaults only for arguments a binding may leave out.
- Loading states: the
create_task()example dropscancel_async_on_disconnect, which only acts on a legacy view. TheLiveViewreference says so, and the migration guide's "Defaults that changed" lists it: an explicit view's background work is cancelled when the connection closes or the user navigates away. - Installation, Your first LiveView and
QUICKSTART.mdsetLIVEVIEW_CONFIG = {"event_parameter_policy": "strict"}and say why: the guides' examples are written for it, and it is still an opt-in on 2.0.0rc1. The quick start no longer tells you to add**kwargsto every handler. - Authentication: a strict form handler that declares
usernameis never sent the password. - HTTP-only mode, interactive components and the check pages
T027,V016andV026no longer advise stating a legacy policy. The cheat sheet, navigation and forms pass arguments asdj-value-*and describe only strict handlers.
tests/test_doc_snippets_execute.pynow runs every block under the strict parameter policy, holds every handler a block declares todjust.V016even when it is not fired, refuses a view or handler that states the legacy policy, fires a handler that needs arguments with what its template binding sends,test_docs_pass_event_arguments_as_dj_valuescans every website page for adata-*event argument, andtest_dj_value_arguments_match_the_documented_handlerchecks that eachdj-value-*argument a page's markup sends is a parameter of the handler the page defines. A block a migration guide shows as 1.3 code is marked<!-- doc-snippet-check: before -->: parsed, not executed, and allowed only in the migration guide anddocs/API_STABILITY.md.- Events teaches the strict rules (the signature is the contract; the
browser sends
Removed
- djust_components/table.html and the filters only it used are removed (#3869). A project override of djust_components/table.html (the documented way to change the row-click script's
/static/prefix) no longer has any effect:{% data_table %}is drawn by the native handler on both engines. Removed with it: the template filterstable_cell,table_href,table_has_href,table_widthandtable_width_attrs(a template that used them outsidetable.htmlmust read the row itself). - Removed time-travel debugging (#4184, owner decision 2026-11-15).
Recording and Share worked on explicit views (a redacted, read-only
history); jumping back, restoring one component and forward replay worked
only on legacy views. Removed: the view attributes
time_travel_enabledandtime_travel_excluded_fields; the moduledjust.time_travel(withTimeTravelBufferandEventSnapshot);djust.bug_capture.encode_view_state(it read the buffer);djust.serialization.decimal_tags_to_strings(its only caller was the buffer's display); the WebSocket framestime_travel_jump,time_travel_component_jump,forward_replayandbug_capture_shareand the server framestime_travel_state,time_travel_eventandbug_capture_share_result; the client eventsdjust:time-travel-state,djust:time-travel-eventanddjust:bug-capture-share-result(the new Share replaces the last: it copies the blob itself and dispatches nothing); the debug panel's Time Travel tab; theLIVEVIEW_CONFIG/DJUST_CONFIGkeystime_travel_enabledandtime_travel_max_events; and system checksdjust.C501,djust.C502anddjust.V014. Lost: stepping the view back, restoring one component, forward replay with edited parameters. Kept: the per-event history (the debug panel's State tab lists each event with the state after it and what changed), the Events tab's "Replay this event", and bug-capture Share, now on the State tab: it builds thedjbug1.blob in the browser from that history, with the event's real patches (the old button re-rendered after the fact and sent[]), leaving out the names inLIVEVIEW_CONFIG['bug_capture_default_scrub']. The replay viewer, snapshot store anddjust replayCLI are unchanged. Nothing that turned the feature on is ignored: the two view attributes are refused withImproperlyConfiguredwhen the class is created, the two config keys at startup,from djust import time_travelandfrom djust.bug_capture import encode_view_stateraiseImportErrornaming the replacement, and an older client that sends a removed frame gets the standardUnknown message typeerror on a connection that keeps working. Signed back-navigation snapshots andpersist=state on a reconnect are a different feature and are unchanged. - Removed the
reset_view_stateandeval_handlerdebug endpoints (#4184, with the legacy policy). They worked only on views that stateexposure_policy = "legacy"(every other view got409). Removed with them:djust.observability.dry_run(DryRunContext,DryRunViolation) and the MCP toolseval_handlerandreset_view_state. The read-only observability endpoints and their MCP tools stay.