Upgrading from rc2. Two behaviour changes to check.
set_changed_keys()now sends a diff instead of the whole page (#4286); callrequest_full_render()where a handler really needs full HTML. Strict parameter refusals now name the rule that failed and addmissing_paramstovalidation_details(#4287). New in rc3:DJUST_UNSUPPLIED_NAMES = "error"makes a template name the view never supplies fail under test instead of rendering blank (#4279), anddjust.testing.persisted_state(view)shows what an explicit view would save (#4280). As in rc2, explicit exposure is the default and an attribute set onselfwithoutstate(...)renders empty with no error;exposure_policy = "legacy"and opt-in strict parameters still work in rc3 and are removed before 2.0.0 final (#4171, #4189). See the 2.0 migration guide.
Added
DJUST_UNSUPPLIED_NAMESmakes an unsupplied template name fail under test (#4279). AddedDJUST_UNSUPPLIED_NAMES("debug"default,"warn","error"):"error"raisesUnsuppliedTemplateNameErroron every render of an explicit view whose template reads a name the view holds but nothing supplies, so a test run (whereDEBUGis off and thedjust.exposurenotice never fires) fails instead of rendering blank;"warn"logs whateverDEBUGis. Names a context processor supplies (user,messages, ...) are not reported. The value is case-insensitive; an invalid one is a newdjust.C043error atmanage.py checkand, at render time, is logged once and behaves as"debug".UnsuppliedTemplateNameErroris importable fromdjust.testing.djust.testing.persisted_state(view)shows what an explicit view would save (#4280). Addeddjust.testing.persisted_state(view)andLiveViewTestClient.persisted_state(): the state an explicit view would save, split by destination (server,snapshot,client, automatic state and its size), read-only._get_private_state()raises on an explicit view; this is the replacement for asserting that a value a page only reads is not persisted.
Changed
- HTTP-fallback pages with
{% dj_flash %}or otherdj-update="ignore"regions are answered with patches (#4283). Since #4108 any render that helddj-updategot the whole page for every fallback event, and{% dj_flash %}renders adj-update="ignore"container, so most apps with flash messages never got patches. The DOM shape on both sides now leaves an ignored element's children out (the client owns them), and an answer is the whole page only when a patch would address the ignored element itself.dj-update="append","prepend","replace"anddj-virtualstill select the whole page. A client built before this change computes the old shape for such a page and keeps getting whole pages. set_changed_keys()now sends a diff, not the whole page (#4286). Both forms still force the turn to render past the unchanged-state skip (and still win overskip_render()), but the render is diffed and sent as apatchon the view route (a handler reached through acomponent_idevent still answers with the full-HTMLcomponent_eventframe), without the DJE-053 warning, so focus, a caret and an open native dialog survive it. A full-HTML render already required by the framework (a restore, a dropped save) is not downgraded.request_full_render()(and assigningself._force_full_html = True) still sends full HTML.- Strict parameter errors say which rule failed (#4287). A refused strict event now names the rule (a required argument is missing, an undeclared argument was sent, a value was supplied both positionally and by name, too many positional arguments, a positional-only name sent by keyword) and the declared parameters involved, but never a value, an undeclared key or a count of them.
validation_detailsgainsmissing_params(declared names,[]when none), and the server logs the undeclared key names at DEBUG on thedjust.validationlogger.
Fixed
- A tick, push or
db_notifyturn whose session save hits a database error now logs a warning instead of being treated as a logout and dropped silently (#4274). Django's database session store raisesUpdateErrorfor any database error on the update, not only for a deleted row. djust now checks whether the session row still exists: only a row that is gone is a logout (dropped quietly, as before); otherwiseSession writes of a <source> turn were not storedis logged at WARNING. - Under explicit exposure, the queries a render makes after
get_context_data()now run insideLIVEVIEW_CONFIG["sync_turn_wrapper"]'s"render"step, and count toward a"render"query budget (#4276). A QuerySet returned fromget_context_data()was evaluated after the wrapped call returned (the explicit JIT, the rows listed for the template), and a relation the template follows on a model ({{ me.groups.count }}) was read by the Rust render, both with no wrapper scope: a row-level security wrapper saw none of the caller's rows._sync_state_to_rust()and therender()/render_full_template()/render_with_diff()methods are now the"render"step as a whole; the steps inside nest, so one render enters the wrapper once. Template-time hooks ({% live_form %},{% live_field %},{{ component }}, a sticky{% live_render %}) therefore also run under"render"now, and an HTTP page GET enters"render"three times (itsget_context_data()together with the context processors and the normalizing of the context's models, whose@propertymethods may query; the page render; the diff-baseline render). A background render (an async result, a push) and a sticky recovery render are one"render"step each. A wrapper that suppresses a render's exception now makes the render raiseRuntimeErrorinstead of returningNone. A view near its"render"budget may now report over. template_paths()follows an{% include %}inside{% tab %}and{% split_pane %}bodies (#4277). Fixedtemplate_paths()(and the JIT serializer, T027 and the unsupplied-name notice that read it) missing a{% include %}inside{% tab %}and{% split_pane %}bodies. Component bodies are now followed for path extraction; every other opaque raw-block body keeps its skip. The{% pane %}separator no longer makes a wholesplit_panebody contribute nothing.djust.T027follows{% extends %}chains, includes andget_context_data()overrides that return a local (#4278).djust.T027no longer skips a view silently because its template uses{% extends %}or because itsget_context_data()returns a local (ctx = super().get_context_data(**kwargs); ctx["x"] = ...; return ctx, includingctx.update(...)andctx.setdefault(...)). Atemplate_nameview is read through its{% extends %}chain and{% include %}partials, so a name read only in a base template or an include is reported (without a line number); names a mixin's provider contract renders (such asTenantMixin'stenant) count as supplied, as does every name a configuredTEMPLATEScontext processor supplies (user,messages, a project processor's keys). The Info message names up to five skipped views. What the check still cannot follow (an override that passes the context to a helper, an inlinetemplatewith{% extends %}) is counted in onedjust.T027Info message. Expect new T027 warnings on projects whose views extend a base template: they are real names that render empty.- A whole-page answer no longer drops changes to top-level children without an
idwhen the render holds adj-updateelement (#4283).applyDjUpdateElementsupdated only the root's top-level children that carry anid, so on a page with{% dj_flash %}(adj-update="ignore"container) a toggled<p>never appeared, on the HTTP fallback and on WebSockethtmlframes alike. The answer is now morphed as a whole, as one withoutdj-updateis: an ignored container keeps the client's children, an append/prepend container its accumulated rows (also when id-less siblings before its wrapper are added or removed), and a focused field its typed text. Adj-updatecontainer the new render no longer contains is now removed, where the old pass kept it. The HTTP fallback also detects client-owned regions by attribute instead of by text, sodj-updatewritten in a page's content (a code sample) no longer turns patch answers off. - A named component no longer breaks a strict handler that does not declare
name(#4285). A component's identityname({% toggle_group name=... %}, orComponent(name=...)throughevent_attrs) is now markeddata-djust-optional="name", and the strict client sends it only when the handler declaresnameor has a**catch-all, as it already does for generatedvalue,fieldandkey.toggle_groupstampeddj-value-nameeven when unnamed, so every toggle group refused a strict handler withoutname. The server contract is unchanged: an undeclarednamethat is sent, such as a hand-writtendj-value-name, is still refused, and legacy handlers still receive it. - An open
{% modal native=True %}stays open across a full-page update (#4286). A full-pagehtml_update(fromrequest_full_render(), a restore or a recovery) morphed the<dialog>against server HTML that never carriesopen, so the client removed it and the dialog closed. The morph now keepsopenon a<dialog dj-dialog="open">; a server close (dj-dialog="close") still closes it, and a<dialog>withoutdj-dialogbehaves as before.
Documentation
- The 2.0 migration guide and the best-practices guide say that a page GET no longer stores the view in the state backend, so the
Large LiveView statewarning no longer fires for page loads, and where a view's size is bounded now (#4281). The removal itself shipped in 2.0.0rc1 (the legacy Rust render cache, exposure-flip row 8). What a view persists is bounded instead:persist="server"fields at 64 KB, automatic state with a warning at 100 KB and a refusal at 512 KB (state_too_large). A budget test measuresdjust.testing.persisted_state(view).automatic_bytes(#4280; an explicit view: a legacy view raisesTypeError, and a state over its limit raisesStateLimitExceeded). - Migration guide:
page_titleis reserved, and a field namedstateshadowsstate()(#4282). Migration guide:page_titleis a framework setting that explicit exposure never supplies to the template (setself.page_titlefor the tab, return it fromget_context_data()for{{ page_title }}), and astate()field namedstateshadowsstate()for the rest of the class body (TypeError: 'StateProperty' object is not callable).