Skip to main content

fajfield-reports (Python)

Render invoices, statements and multi-page reports to PDF from Python: Django, Flask, FastAPI, Odoo add-ons, scripts and scheduled jobs. Design the template in the free Fajfield report designer, export it as .fjt, and render it with your data.

Think RDLC or Crystal Reports for Python, without Windows. Tables continue across pages with the header repeated, groups get subtotals, and "Page 2 of 5" is always right.

The package talks to a Fajfield report server you run yourself, so your data stays on your network. No dependencies: only the Python standard library.

Install

pip install fajfield-reports

Start a report server (once, on any machine your app can reach):

docker run -p 8080:8080 -e API_KEYS=change-me -v ./templates:/templates fajfield/reports-server
# or, with Node 18+:
npx @fajfield/reports-server serve --templates ./templates

Render a report

from fajfield_reports import ReportClient

client = ReportClient("http://localhost:8080", api_key="change-me")

client.render_to_file("invoice", {
    "company":  {"name": "Harbour Foods Co."},
    "customer": {"name": "Fresh Mart", "address": "Dubai"},
    "invoice":  {"no": "INV-0452", "date": date.today()},
    "items":    [{"name": l.product, "qty": l.qty, "rate": l.price, "taxRate": 0.05} for l in order.lines],
}, "invoice.pdf")
  • Template: the name of a template stored on the server ("invoice"), a path to a .fjt file, or the template as a dict.
  • Data: one key per dataset in the template: a list for rows, a dict for single records. Decimal, date, datetime, UUID, dataclasses and named tuples are converted for you.

Django

from django.http import HttpResponse

def invoice_pdf(request, pk):
    pdf = client.render("invoice", invoice_data(pk))
    return HttpResponse(pdf, content_type="application/pdf")

FastAPI

from fastapi.responses import Response

@app.get("/invoices/{pk}.pdf")
def invoice_pdf(pk: int):
    return Response(client.render("invoice", invoice_data(pk)), media_type="application/pdf")

Warnings and errors

r = client.render_result("invoice", data)
r.pdf, r.pages, r.warnings   # e.g. ['No data for "customer". Pass it as data: { customer: { ... } }.']

Problems the report can live with (missing data, bad barcode data) come back as warnings; the PDF is still made. Real errors raise ReportError with a plain message and the HTTP status: 400 bad request or template, 401 wrong API key, 404 unknown template, 0 server not reachable.

Settings

ReportClient() with no arguments reads FAJFIELD_REPORTS_URL (default http://localhost:8080) and FAJFIELD_REPORTS_KEY from the environment.

Also from Fajfield

Report designer · JavaScript · Flutter · .NET · Report server

MIT license. Made by Fajfield: research and development for ERP, warehouse, POS and business data.

Metadata

Release files for fajfield-reports 0.1.0

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

Source distribution (sdist)

Source distribution for fajfield-reports 0.1.0
File Size Uploaded Provenance Actions
fajfield_reports-0.1.0.tar.gz 6.9 kB Without provenance Details for fajfield_reports-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for fajfield-reports 0.1.0
File Interpreter ABI Platform Actions
fajfield_reports-0.1.0-py3-none-any.whl Python 3 none any Details for fajfield_reports-0.1.0-py3-none-any.whl

Total release size: 13.4 kB

Release files / fajfield_reports-0.1.0.tar.gz

Download URL fajfield_reports-0.1.0.tar.gz
Size 6.9 kB
Tags Source
SHA-256 checksum
How to use checksums
302e6532e0a88742e9f3140742e6bb76d03de4fe17ffd6b750c00a497e78aa5b
BLAKE2b-256 checksum
How to use checksums
6d1958011143818c8025ce657820d2cfb67e76dea434b73b882a5256c322f34f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Release files / fajfield_reports-0.1.0-py3-none-any.whl

Download URL fajfield_reports-0.1.0-py3-none-any.whl
Size 6.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2abb9f92a652ae208b38df7258776f075bc339f1b1bc49e3275e0089c4a797e5
BLAKE2b-256 checksum
How to use checksums
36048d799db61cb583d122abd2e7477b7d363286876ab2c47786b4255ba1859b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Security for fajfield-reports 0.1.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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