GSoC 2026 Proposal: Ergonomic Control Over Missing Variables in Django Templates


Summary

In the Django Template Language (DTL), missing variables currently fail silently by returning an empty string. While string_if_invalid exists, it is a global setting that lacks the surgical precision modern developers need.

This project aims to introduce Ergonomic Control Over Missing Variables, providing a way to opt-in to stricter error reporting at a more granular level (per template or per block) without breaking backward compatibility.

Why this is important

  • Faster Debugging: Developers spend significant time hunting down typos in templates that don’t raise errors.

  • Production Safety: Prevent “broken” UI states where critical data is missing but the page still renders.

  • Modern DX: Aligns Django with modern frontend expectations of explicit error handling.

Key Goals

  1. Granular Strictness: Allow developers to trigger exceptions for missing variables in specific scopes.

  2. Enhanced Context: Improve error messages to include the template name and line number for missing variables.

  3. Opt-in Philosophy: Ensure that existing projects remain unaffected unless they choose to use the new features.

:link: Full Proposal & Technical Draft

I have outlined the implementation strategy, including potential changes to the Engine and Template classes, in my detailed proposal: :backhand_index_pointing_right: Read the Full Proposal on GitHub

1 Like