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_formsetBEFOREdjadminfor template override - Installs
formsetdependency - 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 supportconditional_fields- Show/hide field logiccomputed_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
- Layout API Overview - Layout API fundamentals
- Layout Components Reference - All components
- Django Admin Migration Guide - Migrating from Django admin
- Layout Examples - Common patterns
Plugin Documentation
- Layout Integration Guide - How the plugin works
- Inline Editing Guide - Collections and nested forms
- Conditional Fields Guide - Show/hide logic
- Computed Fields Guide - Auto-calculated values
- Renderer Customization Guide - Custom styling
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file djadmin_formset-0.1.3.tar.gz.
File metadata
- Download URL: djadmin_formset-0.1.3.tar.gz
- Upload date:
- Size: 27.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dc9aed6b8adbcda2ef64c82d68f336cca3c6a28b8c2a1a0a6a4a944a104d0a60
|
|
| MD5 |
fc3f8b2fe4d2b601a1927e165578d517
|
|
| BLAKE2b-256 |
c94a97d1c88665fd9c45e971aabeb7a4c808b29f2b904abfea988c4f883d5112
|
File details
Details for the file djadmin_formset-0.1.3-py3-none-any.whl.
File metadata
- Download URL: djadmin_formset-0.1.3-py3-none-any.whl
- Upload date:
- Size: 27.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
550024900bcb66a5e4d473c79a252083d233a8ede04f4b2d7d686bdfe8b349a4
|
|
| MD5 |
09f1a33b0863f5974b28a385ca83955e
|
|
| BLAKE2b-256 |
d53d21d3750d924894422f832984c0d97059923f2f7ad1bb39c39501f41e17d1
|