Skip to content

v2.0.0rc3

Pre-release
Pre-release

Choose a tag to compare

@github-actions github-actions released this 24 Nov 00:38
· 47 commits to main since this release
29b3234

Upgrading from rc2. Two behaviour changes to check. set_changed_keys()
now sends a diff instead of the whole page (#4286); call
request_full_render() where a handler really needs full HTML. Strict
parameter refusals now name the rule that failed and add
missing_params to validation_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), and
djust.testing.persisted_state(view) shows what an explicit view would save
(#4280). As in rc2, explicit exposure is the default and an attribute set on
self without state(...) 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_NAMES makes an unsupplied template name fail under test (#4279). Added DJUST_UNSUPPLIED_NAMES ("debug" default, "warn", "error"): "error" raises UnsuppliedTemplateNameError on every render of an explicit view whose template reads a name the view holds but nothing supplies, so a test run (where DEBUG is off and the djust.exposure notice never fires) fails instead of rendering blank; "warn" logs whatever DEBUG is. Names a context processor supplies (user, messages, ...) are not reported. The value is case-insensitive; an invalid one is a new djust.C043 error at manage.py check and, at render time, is logged once and behaves as "debug". UnsuppliedTemplateNameError is importable from djust.testing.
  • djust.testing.persisted_state(view) shows what an explicit view would save (#4280). Added djust.testing.persisted_state(view) and LiveViewTestClient.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 other dj-update="ignore" regions are answered with patches (#4283). Since #4108 any render that held dj-update got the whole page for every fallback event, and {% dj_flash %} renders a dj-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" and dj-virtual still 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 over skip_render()), but the render is diffed and sent as a patch on the view route (a handler reached through a component_id event still answers with the full-HTML component_event frame), 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 assigning self._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_details gains missing_params (declared names, [] when none), and the server logs the undeclared key names at DEBUG on the djust.validation logger.

Fixed

  • A tick, push or db_notify turn 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 raises UpdateError for 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); otherwise Session writes of a <source> turn were not stored is logged at WARNING.
  • Under explicit exposure, the queries a render makes after get_context_data() now run inside LIVEVIEW_CONFIG["sync_turn_wrapper"]'s "render" step, and count toward a "render" query budget (#4276). A QuerySet returned from get_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 the render() / 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 (its get_context_data() together with the context processors and the normalizing of the context's models, whose @property methods 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 raise RuntimeError instead of returning None. A view near its "render" budget may now report over.
  • template_paths() follows an {% include %} inside {% tab %} and {% split_pane %} bodies (#4277). Fixed template_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 whole split_pane body contribute nothing.
  • djust.T027 follows {% extends %} chains, includes and get_context_data() overrides that return a local (#4278). djust.T027 no longer skips a view silently because its template uses {% extends %} or because its get_context_data() returns a local (ctx = super().get_context_data(**kwargs); ctx["x"] = ...; return ctx, including ctx.update(...) and ctx.setdefault(...)). A template_name view 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 as TenantMixin's tenant) count as supplied, as does every name a configured TEMPLATES context 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 inline template with {% extends %}) is counted in one djust.T027 Info 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 id when the render holds a dj-update element (#4283). applyDjUpdateElements updated only the root's top-level children that carry an id, so on a page with {% dj_flash %} (a dj-update="ignore" container) a toggled <p> never appeared, on the HTTP fallback and on WebSocket html frames alike. The answer is now morphed as a whole, as one without dj-update is: 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. A dj-update container 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, so dj-update written 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 identity name ({% toggle_group name=... %}, or Component(name=...) through event_attrs) is now marked data-djust-optional="name", and the strict client sends it only when the handler declares name or has a ** catch-all, as it already does for generated value, field and key. toggle_group stamped dj-value-name even when unnamed, so every toggle group refused a strict handler without name. The server contract is unchanged: an undeclared name that is sent, such as a hand-written dj-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-page html_update (from request_full_render(), a restore or a recovery) morphed the <dialog> against server HTML that never carries open, so the client removed it and the dialog closed. The morph now keeps open on a <dialog dj-dialog="open">; a server close (dj-dialog="close") still closes it, and a <dialog> without dj-dialog behaves 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 state warning 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 measures djust.testing.persisted_state(view).automatic_bytes (#4280; an explicit view: a legacy view raises TypeError, and a state over its limit raises StateLimitExceeded).
  • Migration guide: page_title is reserved, and a field named state shadows state() (#4282). Migration guide: page_title is a framework setting that explicit exposure never supplies to the template (set self.page_title for the tab, return it from get_context_data() for {{ page_title }}), and a state() field named state shadows state() for the rest of the class body (TypeError: 'StateProperty' object is not callable).

What's Changed

  • rc3 train 1: exposure tooling and runtime fixes from the rc2 field reports by @johnrtipton in #4284
  • rc3 train 2: strict-parameter identity name, clearer refusals, set_changed_keys keeps modals open by @johnrtipton in #4288
  • chore: release 2.0.0rc3 by @johnrtipton in #4289

Full Changelog: v2.0.0rc2...v2.0.0rc3