Skip to main content

django-nifty-layout

PyPI Version Test with tox Code style: black

Version: 0.2.2

A simple but flexible layout tool for composing and transforming data for structured template components. Inspired by crispy-forms Layout, but without the forms.

django-nifty-layout is free software distributed under the MIT License.

Quick Start

  1. Install the django-nifty-layout package from PyPI

    $ pip install django-nifty-layout
    
  2. Go grab a drink, you are all done!

Sample Usage

layout.py

from django.utils.formats import date_format

from nifty_layout.components import (
   DictCompositeNode as Dct,
   FieldNode as Fld,   
   Seq,
)

# ----- Safe Date Formatter ----- #
date_formatter = lambda val, **kwargs: "" if val is None else date_format(val, SHORT_DATE_FORMAT)

layout = Dct(
    dict(
        overview=Seq(
             "title",
             Fld("date", formatter=date_formatter),
             report_type",
             "location",
             labeller="Overview",
        ),
        contacts=Seq(
            Dct(dict(
                    name="contact_name",
                    contact_methods=Seq("contact_email"),
                ), labeller="Primary Contact"
            ),
            Dct(dict(
                    name="reported_by_name",
                    contact_methods=Seq("reported_by_phone_num", "reported_by_email"),
                 ), labeller="Reported By"
            ),
            labeller="Contacts",
        ),
        ...
    )
)

views.py

def report_view(request, pk):
   ...
   obj = Report.objects.get(pk=pk)
   ...
   return render(request, "template.html", dict(report=layout.bind(obj)))

template.html

...
<div class="report>
  <h2>report.overview.label</h2>
  {% for node in report.overview %}
      <div class="row">
         <div class="col label">{{ node.label }}</div>
         <div class="col value">{{ node.value|default:"" }}</div>
      {% endfor %}
      </div>
  {% endfor %}
  <div class="row">
    {% for contact in report.contacts %}
      <div class="col">
        {% include "contact_card.html" %}
      </div>
    {% endfor %}
  </div>
   ...
</div>   

Get Me Some of That

MIT License

Check Out the Demo App

  1. pip install -e git+https://github.com/powderflask/django-nifty-layout.git#egg=django-nifty-layout
  2. inv demo.install ** coming soon **
  3. python demo_app/manage.py runserver

See demo_app/README

Acknowledgments

This project would be impossible to maintain without the help of our generous contributors

Technology Colophon

Without django and the django dev team, the universe would have fewer rainbows and ponies.

This package was originally created with cookiecutter and the cookiecutter-powder-pypackage project template.

For Developers

Install invoke, pip-tools, tox for all the CLI goodness

 pip install invoke pip-tools tox

Initialise the development environment using the invoke task

inv tox.venv

Or create it with tox directly

tox d -e dev .venv

Or build and install the dev requirements with pip

inv deps.compile-dev
pip install -r requirements_dev.txt

Tests

pytest

or

tox r

or run tox environments in parallel using

tox p

Code Style / Linting

$ isort
$ black
$ flake8

Versioning

Build / Deploy Automation

Metadata

Release files for django-nifty-layout 0.2.2

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-nifty-layout 0.2.2
File Size Uploaded Provenance
django_nifty_layout-0.2.2.tar.gz 15.2 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for django-nifty-layout 0.2.2
File Interpreter ABI Platform
django_nifty_layout-0.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 28.9 kB

Release files / django_nifty_layout-0.2.2.tar.gz

Download URL django_nifty_layout-0.2.2.tar.gz
Size 15.2 kB
Tags Source
SHA-256 checksum
How to use checksums
a7289ddac4bd11361f0c4b64be665828e7283508381b066c194f1fc8ed21a6cf
BLAKE2b-256 checksum
How to use checksums
6cdbe510b7d78bcd5507d0fc9af4dc00ad083d0e1e1f55e6822802af7d23eaaf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jun 7, 2026.

Transparency log

Release files / django_nifty_layout-0.2.2-py3-none-any.whl

Download URL django_nifty_layout-0.2.2-py3-none-any.whl
Size 13.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f10e5e17a06d9c010703026a4602eb56c726b6531e3b6a104866c59871172e7e
BLAKE2b-256 checksum
How to use checksums
5ea475736306f4b70c553201ccfc8dbf793ba09e27967f4213f78d2ab031b773
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jun 7, 2026.

Transparency log

Security for django-nifty-layout 0.2.2

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for django_nifty_layout-0.2.2.tar.gz

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 Jun 7, 2026.

Transparency log

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.

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