Skip to main content

Django-formset integration for django-admin-deux Layout API

Project description

djadmin-formset

Django-formset integration plugin for django-admin-deux Layout API.

Overview

This plugin provides full django-formset FormCollection support for the django-admin-deux Layout API, enabling advanced form features:

  • Inline Editing: Collection components for related objects
  • Conditional Fields: Show/hide fields based on other field values
  • Computed Fields: Auto-calculate field values from expressions
  • Client-Side Validation: Real-time validation without page refresh
  • Drag-and-Drop Ordering: Sortable collections
  • Progressive Enhancement: Works alongside core djadmin without breaking basic forms

Installation

# Install from PyPI (when published)
pip install djadmin-formset

# Or install with django-admin-deux
pip install django-admin-deux[djadmin-formset]

Configuration

Automatic Configuration (Recommended)

Use djadmin_apps() for zero-configuration setup:

# settings.py
from djadmin import djadmin_apps

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    # ... other Django apps
    'myapp',
] + djadmin_apps()  # Automatically includes djadmin-formset in correct order

The plugin system automatically:

  • Installs djadmin_formset BEFORE djadmin for template override
  • Installs formset dependency
  • Handles all ordering requirements

Manual Configuration

If you need manual control over INSTALLED_APPS:

INSTALLED_APPS = [
    # ... Django apps ...
    'formset',           # django-formset (dependency)
    'djadmin_formset',   # MUST come BEFORE djadmin for template overrides
    'djadmin',
    # ...
]

CRITICAL: djadmin_formset MUST appear before djadmin in INSTALLED_APPS. This ensures Django's template loader finds the FormCollection templates before the standard form templates.

Usage

Basic Inline Editing

from djadmin import ModelAdmin, register, Layout, Field, Collection

@register(Author)
class AuthorAdmin(ModelAdmin):
    layout = Layout(
        Field('name'),
        Field('birth_date'),
        Collection('books',
            model=Book,
            fields=['title', 'isbn', 'published_date'],
            is_sortable=True,
        ),
    )

Conditional Fields

from djadmin import ModelAdmin, register, Layout, Field

@register(Product)
class ProductAdmin(ModelAdmin):
    layout = Layout(
        Field('name'),
        Field('product_type'),
        Field('weight', show_if=".product_type === 'physical'"),
        Field('file_size', show_if=".product_type === 'digital'"),
    )

Computed Fields

from djadmin import ModelAdmin, register, Layout, Field, Row

@register(OrderItem)
class OrderItemAdmin(ModelAdmin):
    layout = Layout(
        Row(
            Field('quantity', css_classes=['flex-1']),
            Field('price', css_classes=['flex-1']),
            Field(
                'total',
                calculate='.quantity * .price',
                css_classes=['flex-1']
            ),
        ),
    )

Features Provided

This plugin advertises the following features to the djadmin core:

  • collections / inlines - Inline editing support
  • conditional_fields - Show/hide field logic
  • computed_fields - Auto-calculated fields

Requirements

  • Python 3.11+
  • Django 5.2+
  • django-admin-deux >= 0.1.0
  • django-formset >= 1.3

Development Status

Status: Alpha - Day 18 of Milestone 3 implementation (Phase 2 complete)

This plugin is under active development as part of Milestone 3 (Layout API & Django-Formset Integration).

Completed:

  • ✅ FormFactory - converts layouts to FormCollections
  • ✅ DjAdminFormRenderer - Tailwind CSS themed renderer
  • ✅ Plugin hooks - mixin-based form conversion
  • ✅ Template overrides - django-formset JS/CSS integration
  • ✅ Integration tests - all features tested
  • ✅ Comprehensive documentation - 5+ guides

In Progress:

  • 📋 Final polish and release preparation (Days 19-20)

Documentation

Comprehensive documentation available in the main django-admin-deux docs:

Core Documentation

Plugin Documentation

License

MIT License - See LICENSE file for details

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

djadmin_formset-0.1.1.tar.gz (23.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

djadmin_formset-0.1.1-py3-none-any.whl (24.5 kB view details)

Uploaded Python 3

File details

Details for the file djadmin_formset-0.1.1.tar.gz.

File metadata

  • Download URL: djadmin_formset-0.1.1.tar.gz
  • Upload date:
  • Size: 23.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for djadmin_formset-0.1.1.tar.gz
Algorithm Hash digest
SHA256 d9be22cd39681cf6f84aea66637761f26cb3242aa91dff7cfff6d21d7f992c67
MD5 5bca86c06e029f6536a057bdf2203b89
BLAKE2b-256 b1c95d5cc5baee712701447edc9fdb46350dd8880f51c5e5d44d2cf4970ad536

See more details on using hashes here.

File details

Details for the file djadmin_formset-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for djadmin_formset-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b0cbf67b543641db768f44c9db8d51c2c07e7be9dec996a3f79330f393eef7e2
MD5 abe3df0c2065459d5adeaf75d81a1622
BLAKE2b-256 02ccdd9b1ec5d53fb2e7946c6d3c2c2da7048bf299f7d00e081350819dc16863

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page