djust 1.3.0rc17

Pre-release Released
Install
pip install djust==1.3.0rc17

This is a pre-release. djust 1.3.0 has shipped since.

Part of djust 1.3 — read the 1.3 release notes.

Before you upgrade, read the upgrade guide.

Fixed

  • A model held in a container prints as its text when a filter prints the whole container. {{ rows|pprint }} and {{ rows|json_script:"x" }} over a list, tuple, QuerySet or dict holding models now write each model's str(), as {{ rows }} does, instead of the model's serialized mapping. pprint writes [Account:a1, Account:a2] (Django writes the repr()); json_script writes ["Account:a1", "Account:a2"] through the usual escaping (Django raises TypeError). A named read ({{ r.name }}), {{ rows }}, |length, an ordinary dict and the data itself (get_state(), the snapshot) are unchanged. To hand a model's fields to JavaScript, pass a plain dict of the fields you want (not the output of normalize_django_value, which carries a __str__ text). Needs the rebuilt _rust module.
  • The JIT attribute gate applies the column-type floor like the serialization path does. optimization/codegen.py::emittable_names, the gate behind the compiled serializers and the Rust serializers, decided by attribute name only, so a column the type floor drops (a BinaryField, a type named in LIVEVIEW_CONFIG['sensitive_field_types'], an encrypted-named type) was read by a template that named it. The gate now asks DjangoJSONEncoder._attr_is_readable, the name rules followed by the type floor, which neither an allowlist nor an opt-out lifts. The gate's cache key carries the model class and the configured types, and a full cache is cleared rather than frozen. The floor governs columns: a property, method, annotation or values_list row carrying the same value is outside it, as on the eager path. Upgrade note: a JIT page that displayed an encrypted-named (or configured-sensitive, or binary) column now renders it empty; to show such a value deliberately, precompute a plain value in get_context_data() or a property, or remove the type from LIVEVIEW_CONFIG['sensitive_field_types'] / rename the field class. 22 regression cases in python/djust/tests/test_jit_gate_type_floor.py.
  • A model is not a mapping to a template. On a model held in LiveView state or in a container, {{ r.items }}, {{ r.values }} and {{ r.keys }} resolve to nothing (a bare {{ r.items }} prints nothing on most entries, and the text dict_items([]) (dict_keys([]), dict_values([])) on LiveView for a list, QuerySet or top-level model and for QuerySet rows on DjustTemplateBackend, where Django prints nothing; no entry is ever printed), {% for k in r %}, |unordered_list, |safeseq and |escapeseq refuse the model as Django does (|join returns the model's text), and |stringformat:"(name)s", {% if 'name' in r %} / not in (both take the else branch) and |pluralize treat it as the non-mapping Django does, instead of reading the map the model was serialized to. A named read ({{ r.name }}) is unchanged. The sinks go by the full identity shape a serializer stamps (__str__, __model__ and pk), and a model whose __str__ is a SafeString is recognised like any other; a dict from user data that only carries a __str__ key stays a dict (views, iteration, pprint, json_script), while {{ d }} and |length of it keep going by the __str__ text as before. Needs the rebuilt _rust module.

All releases · Atom feed