Upgrading from rc3. Under explicit exposure, a Model, model list or QuerySet that the template reads only plain fields off now reaches the renderer reduced to those fields, as on 1.x, instead of every concrete column (#4290). If you passed values through
self.serialize_for_template()to get that shape, the workaround is no longer needed. New in rc4:djust.testing.rendered_state(view)shows what a render handed the template engine (#4291). Two performance fixes:serialize_for_template()reads the cached template source (#4294), and a live mount skips re-rendering a page shell that holds no child view (#4295). As in rc3,exposure_policy = "legacy"and opt-in strict parameters still work and are removed before 2.0.0 final (#4171, #4189). See the 2.0 migration guide.
Added
djust.testing.rendered_state(view)andLiveViewTestClient.rendered_state()return a detached copy of the state the last render handed the template engine, so a data-minimization test no longer reads the privateview._rust_view.get_state().get_state()under explicit exposure returns onlyclient=Truefields, andpersisted_state()answers what a save keeps, not what the renderer received (#4291).
Fixed
- Explicit exposure no longer hands the renderer every field of a Model or row list the template reads only columns off. A top-level Model, model list or QuerySet whose relations the template does not walk now goes through the template-path JIT, as on 1.x, so the renderer's state (and its snapshot) carries the fields the template names, not every concrete column less
djust_exclude_fields. A single Model whose relations or methods the template walks keeps its normalized fields, and one the template reads nothing off keeps only its identity keys; a row list read with no field path ({% regroup %},{{ rows.0 }}) keeps whole rows, as the JIT gives it (#2736). Adictsort:<variable>naming a non-column keeps the normalized rows. The migration guide notes the change (#4290). template_paths()andserialize_for_template()read the cached template source. WithDEBUGoff they used to resolve the{% extends %}chain and re-inline every{% include %}on each call, so aget_context_data()that callsserialize_for_template()per key paid one full template resolution per key on every render. They now read the per-template source cache every internal caller uses. WithDEBUGon, the unsupplied-name notice (#4279) reads the template once per render, not twice, and once per view class while hot reload is running (its template refresh forgets the copy);DJUST_UNSUPPLIED_NAMES = "error"still reads it once per render (#4294).- A live mount no longer renders the whole page shell when nothing in it can mount a child view. An explicit-exposure view whose page shell comes from
template_namerendered the full page on every WebSocket mount, only to register child views outsidedj-root, and discarded the HTML. The mount now reads the page's template files (thetemplate_namefile, each{% extends %}parent and each{% include %}partial) and skips that render when none nameslive_render, everyextends/includenames a template that resolves, and none loads a tag library beyond Django'sstatic,i18n,l10n,tz,cache,humanizeand djust'slive_tags. An engine'sbuiltins, a djust tag handler registered outside djust, or a view that overridesget_template()keeps the full render. The answer is cached per template while render caches are on (#4295).