Skip to main content

Django Template Reports

Django Template Reports is a Django application that turns PowerPoint (PPTX) and Excel (XLSX) files into reusable templates. Placeholders inside those templates are resolved using your Django models so that you can generate polished reports without hard‑coding the layout.

Key Features

  • PowerPoint and Excel rendering – supply a PPTX or XLSX file and a context dictionary to produce a finished document.
  • Placeholder expressions using {{ }} to access attributes, call methods, filter lists and perform math.
  • Formatting helpers for dates, numbers and string casing (upper, lower, title).
  • Arithmetic operators in expressions (+, -, *, /).
  • Dynamic table and worksheet expansion when a placeholder resolves to a list.
  • Chart support where spreadsheet values inside charts contain placeholders.
  • Permission enforcement – data is filtered based on check_permissions function.
  • Admin integration with a flow to choose a template, configure context and generate ReportRun records. Generated files can be downloaded individually or as a ZIP archive.
  • Configurable filenames using config.filename_template in ReportDefinition.
  • Global context injection for values that should always be available.
  • Context extraction to inspect templates and determine which context keys are required.
  • Image placeholders – shapes or cells starting with %imagesqueeze% or %image% are replaced by an image downloaded from the provided URL.

Codebase Overview

template_reports/ contains the library:

  • models/ – base classes ReportDefinition and ReportRun plus utilities for file storage.
  • admin/ – Django admin classes and views used to generate reports and download them in bulk.
  • office_renderer/ – logic for rendering PPTX and XLSX files. This handles text boxes, tables, charts, worksheets and the %image%/%imagesqueeze% directives.
  • templating/ – the template engine responsible for parsing and evaluating expressions.
  • templates/ and raw_templates/ – the admin templates and example Office templates.
  • tests/ – the test suite.

Start by looking at ReportDefinition in models/base.py and the functions in office_renderer to see how a file is rendered. The templating package is standalone and can be read independently if you want to learn how placeholders are parsed.

Writing Templates

Template files are just normal PowerPoint or Excel documents. No coding or macros are required—just type plain text placeholders where you want dynamic information to appear.

  1. Design your layout. Build the slides or workbook exactly as you would for a static report.
  2. Insert placeholders. Anywhere you would type text you can instead type a placeholder wrapped in {{ and }}:
    • {{ user.name }} – insert a simple value from the context.
    • {{ user.profile__email }} – read nested attributes using . or __.
    • {{ users[is_active=True].email }} – pick a specific item from a list.
    • {{ amount * 1.15 }} – perform calculations.
    • {{ price | .2f }} or {{ name | upper }} – apply formatting filters.
  3. Repeat rows or slides for lists. If a placeholder by itself resolves to a list, extra rows (or slides) will be created so that each item appears separately. This is how you build tables from querysets.
  4. Add images. To include an image from a URL, create a text box or cell that starts with %image% or %imagesqueeze% followed by the address: %image% https://example.com/logo.png %imagesqueeze% https://example.com/logo.png The former keeps the image's aspect ratio while fitting it inside the shape. The latter squeezes the image to exactly fill the shape.
  5. Save the file and register it in the Django admin as a report template.

You can experiment with the example files in template_reports/raw_templates to see common patterns. Remember that all placeholders are plain text—avoid formulas or punctuation that might confuse the parser.

Chart data sheets can also contain placeholders so your graphs update automatically.

Learning More

After trying the example templates in raw_templates/ explore the tests/ directory to see many usage patterns. The test files demonstrate complex placeholders, permission checks and the new image replacement behaviour.

Release files for django-template-reports 0.5.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-template-reports 0.5.3
File Size Uploaded
django_template_reports-0.5.3.tar.gz 14.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-template-reports 0.5.3
File Interpreter ABI Platform
django_template_reports-0.5.3-py3-none-any.whl Python 3 none any Details

Total release size: 32.3 kB

Release files / django_template_reports-0.5.3.tar.gz

Download URL django_template_reports-0.5.3.tar.gz
Size 14.0 kB
Tags Source
SHA-256 checksum
How to use checksums
cdaaa22c367521a7e20c36f95478380d9a1be0e668f81d9691fe67afdd21ae17
BLAKE2b-256 checksum
How to use checksums
92581a9e1dc460fbd44ec7d8f1d1cfefe109f2b0e343643f1921a62cb0a37f90
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 30, 2026.

Transparency log

Release files / django_template_reports-0.5.3-py3-none-any.whl

Download URL django_template_reports-0.5.3-py3-none-any.whl
Size 18.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
133e093cabc48f159ffd4c6ee6d7db13377296df35216300ac948fcc969aa9df
BLAKE2b-256 checksum
How to use checksums
262a9c50d6c6cc7c23e601af1eb8f5e1d1206236c377175d816b95a6042b237f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 30, 2026.

Transparency log

Release history Release notifications | RSS feed

0.5.4

2 release files

This release

0.5.3 This release

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.9

2 release files

0.2.8

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page