Skip to main content

django-zooy

Django form widgets for Carbon Design System and Zooy UI framework.

Installation

pip install django-zooy
# settings.py
INSTALLED_APPS = [
    'django_zooy',
]

Quick Start

from django import forms
from django_zooy import CarbonFormMixin
from django_zooy.carbon import CarbonTextInput, CarbonEmailInput

class ContactForm(CarbonFormMixin, forms.Form):
    name = forms.CharField(widget=CarbonTextInput())
    email = forms.EmailField(widget=CarbonEmailInput())

The CarbonFormMixin automatically injects field labels, help text, validation states, and required attributes into Carbon widgets.

Widgets

Carbon Design System

from django_zooy.carbon import (
    CarbonTextInput,      # <cds-text-input>
    CarbonEmailInput,     # <cds-text-input type="email">
    CarbonPasswordInput,  # <cds-password-input>
    CarbonURLInput,       # <cds-text-input type="url">
    CarbonTelInput,       # <cds-text-input type="tel">
    CarbonNumberInput,    # <cds-text-input type="number">
    CarbonSearchInput,    # <cds-text-input type="search">
    CarbonTextarea,       # <cds-textarea>
)

Widget Configuration

Python snake_case attributes are automatically converted to Carbon's kebab-case:

CarbonTextInput(attrs={
    'label': 'Username',
    'helper_text': 'Enter your username',
    'placeholder': 'johndoe',
    'invalid': False,
    'invalid_text': 'Username is required',
    'size': 'md',  # sm, md, lg
    'enable_counter': True,
    'max_count': 50,
})

Boolean attributes render without values:

  • required=True → required
  • disabled=True → disabled
  • invalid=True → invalid

Form Mixins

CarbonFormMixin

Automatically configures Carbon widgets with form field metadata:

class MyForm(CarbonFormMixin, forms.ModelForm):
    class Meta:
        model = User
        fields = ['username', 'email']
        widgets = {
            'username': CarbonTextInput(),
            'email': CarbonEmailInput(),
        }

Auto-injected attributes:

  • label from field.label
  • required from field.required
  • helper-text from field.help_text
  • disabled from field.disabled
  • invalid and invalid-text from validation errors

Works with Form, ModelForm, and custom form classes. Only affects Carbon widgets.

ZooyFormMixin

Base mixin for Zooy UI integration. Use CarbonFormMixin for Carbon widgets.

Carbon Icons and Pictograms

Server-side SVG rendering of Carbon Design System icons and pictograms. No JavaScript required.

Setup

# settings.py
CARBON_ICONS_PATH = BASE_DIR / 'carbon' / 'icons'
CARBON_PICTOGRAMS_PATH = BASE_DIR / 'carbon' / 'pictograms'  # Optional
# Download icons only
python manage.py fetch_carbon_assets icons

# Download pictograms only
python manage.py fetch_carbon_assets pictograms

# Download both
python manage.py fetch_carbon_assets all

Downloads 2,000+ icons and pictograms from npm to the specified paths.

Usage

{% load carbon %}

{# Icons #}
{% carbon_icon "save" %}
{% carbon_icon "edit" 20 %}
{% carbon_icon "delete" 16 slot="icon" class="text-red-500" %}

{# Pictograms #}
{% carbon_pictogram "accessibility" %}
{% carbon_pictogram "accelerating-transformation" size=64 %}
{% carbon_pictogram "cloud" slot="icon" class="my-pictogram" %}

Icon arguments:

  • name (required) - Icon name from Carbon icons library
  • size (optional) - 16, 20, 24, or 32. Default: 16
  • **attrs (optional) - HTML attributes (slot, class, data-*, etc.)

Pictogram arguments:

  • name (required) - Pictogram name from Carbon pictograms library
  • size (optional) - Display size in pixels. Default: 48
  • **attrs (optional) - HTML attributes (slot, class, data-*, etc.)

Missing icons/pictograms render nothing and log a warning.

Management Command Options

# Force re-download (overwrites existing files)
python manage.py fetch_carbon_assets icons --force
python manage.py fetch_carbon_assets all --force

Add to deployment pipeline:

# Download icons only
RUN python manage.py fetch_carbon_assets icons

# Or download both icons and pictograms
RUN python manage.py fetch_carbon_assets all

API Reference

CarbonWidgetMixin

Base class for all Carbon widgets. Provides:

  • Automatic snake_case → kebab-case attribute conversion
  • Boolean attribute handling
  • Default size (md)
  • Size constants: SIZE_SMALL, SIZE_MEDIUM, SIZE_LARGE

CarbonTextInput

Tooltip constants:

  • Alignment: TOOLTIP_ALIGN_START, TOOLTIP_ALIGN_CENTER, TOOLTIP_ALIGN_END
  • Direction: TOOLTIP_DIR_TOP, TOOLTIP_DIR_RIGHT, TOOLTIP_DIR_BOTTOM, TOOLTIP_DIR_LEFT

Supported attributes:

  • Standard: label, placeholder, required, disabled, readonly
  • Validation: invalid, invalid_text, warn, warn_text
  • Display: size, hide_label, inline
  • Counter: enable_counter, max_count
  • Tooltip: tooltip_alignment, tooltip_direction

CarbonPasswordInput

Same as CarbonTextInput with show_password_visibility_toggle=True by default.

Additional attributes:

  • hide_password_label - Tooltip text for hide password
  • show_password_label - Tooltip text for show password

CarbonTextarea

Same attributes as CarbonTextInput plus:

  • rows - Number of visible text lines
  • cols - Visible width of the text control

Development

git clone https://github.com/trinity-telecomms/django-zooy
cd django-zooy
uv sync --all-extras --all-groups
uv run pre-commit install  # Install git hooks
pytest
ruff check .

Pre-commit Hooks

The project uses pre-commit hooks to ensure code quality:

# Install hooks (one-time setup)
uv run pre-commit install

# Run hooks manually on all files
uv run pre-commit run --all-files

# Hooks run automatically on git commit

Included hooks:

  • Trailing whitespace and file ending fixes
  • Ruff linting and formatting
  • Django-upgrade for Django best practices
  • Bandit security checks

Build and Publish

# Update version in pyproject.toml
uv sync --upgrade --all-extras --all-groups
pytest
rm -rf dist/ build/ *.egg-info/
uv build
uv publish

License

MIT License. See LICENCE for details.

Metadata

Release files for django-zooy 0.8.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 django-zooy 0.8.0
File Size Uploaded Provenance Actions
django_zooy-0.8.0.tar.gz 19.7 kB Without provenance Details for django_zooy-0.8.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-zooy 0.8.0
File Interpreter ABI Platform Actions
django_zooy-0.8.0-py3-none-any.whl Python 3 none any Details for django_zooy-0.8.0-py3-none-any.whl

Total release size: 55.8 kB

Release files / django_zooy-0.8.0.tar.gz

Download URL django_zooy-0.8.0.tar.gz
Size 19.7 kB
Tags Source
SHA-256 checksum
How to use checksums
f5d69c094c936a65f29d168b6ac40fedf44790cc2b924c0333020bdb380aa2f8
BLAKE2b-256 checksum
How to use checksums
bc9e9613999d88bc5b66bc385f95d2d76f2a9eca7bf867699f1ca81a5dc1e2b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / django_zooy-0.8.0-py3-none-any.whl

Download URL django_zooy-0.8.0-py3-none-any.whl
Size 36.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
768abb45b574080b7a078558751c8b40127658d6e13a78e2ebf34f0f49dda4b8
BLAKE2b-256 checksum
How to use checksums
5837c96de5c9db7b702efe2555f1b2cf20849727bdc9418ef42e97ad326a0a4e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for django-zooy 0.8.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.

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