Examples¶
The examples/ directory in the repository contains a full Django project demonstrating all rg.forms features.
Running the example project¶
git clone https://github.com/raccoongang/rg.forms.git
cd rg.forms/examples
uv venv
source .venv/bin/activate
uv pip install -e "..[all]"
python manage.py migrate
python manage.py runserver
Visit http://localhost:8000/ to see all examples.
Included examples¶
Order Form¶
Demonstrates visible_when for conditional field visibility. Fields appear and disappear based on order type selection.
Price Calculator¶
Demonstrates computed fields. The total updates in real time as quantity and price change.
Contact Form¶
Demonstrates required_when for dynamic requirements. Email or phone becomes required based on contact method.
Backend Validation¶
Shows how the backend evaluates all reactive expressions during validation:
- Hidden fields are skipped (even if
required=True) - Dynamic requirements are enforced
- Computed values are recalculated (client value ignored)
Conditional Attributes¶
Demonstrates disabled_when, read_only_when, and help_text_when for dynamic field states.
Cascading Dropdowns¶
Dependent dropdowns with server-side re-rendering via Datastar SSE. Category selection updates available products.
Field Groups¶
Fields organized into sections with shared visible_when rules. Business fields appear only for business accounts.
Source code¶
- Forms:
examples/examples/forms.py - Views:
examples/examples/views.py - Templates:
examples/examples/templates/examples/ - Base template:
examples/templates/base.html