A complete Django demo project showcasing the Forms Builder system with frontend and backend integration.
π Want to get started quickly? Check out the QUICKSTART.md guide!
This example project demonstrates:
- β Django admin integration with form builder
- β Form renderer displaying forms on web pages
- β Visual form builder interface
- β Multi-step wizard forms
- β Form submission handling
- β Example forms with fixtures
- β Complete CRUD operations for forms
- β REST API endpoints
- Python 3.8 or higher
- Node.js 18 or higher (for building frontend components)
- pip (Python package manager)
# From the example-django directory
pip install -r requirements.txt# From the project root (forms-poc/)
cd packages/backend
pip install -e .For production use, you'll want to build the frontend components:
# From the project root (forms-poc/)
npm install
npm run build:allFor development, you can use the components directly from source.
# From the example-django directory
python manage.py migratepython manage.py createsuperuserFollow the prompts to create your admin account.
python manage.py loaddata demo_project/fixtures/example_forms.jsonThis will load three example forms:
- contact-form: Simple contact form
- registration-form: Multi-step registration
- survey-form: Customer satisfaction survey
python manage.py runserverThe server will start at http://127.0.0.1:8000
Visit http://127.0.0.1:8000 to see:
- Overview of features
- Quick links to builder and admin
- Getting started guide
Visit http://127.0.0.1:8000/builder/ to:
- Create forms visually with drag-and-drop
- Configure field properties
- Set up multi-step wizards
- Export form definitions as JSON
Note: The form builder needs the frontend components. For a full demo, build the components first or use the admin interface.
Visit http://127.0.0.1:8000/admin/ to:
- Create and manage form definitions
- View form submissions
- Configure validation rules
- Import/export form JSON
After loading fixtures or creating a form in admin:
- Visit http://127.0.0.1:8000/renderer/contact-form/
- Or http://127.0.0.1:8000/renderer/registration-form/
- Or http://127.0.0.1:8000/renderer/survey-form/
-
Start the builder:
npm run dev:builder
(Run this from the project root)
-
Design your form:
- Open http://localhost:5173
- Drag fields from the left palette
- Click fields to edit properties
- Configure validation rules
- Set up multi-step if needed
-
Export the definition:
- Click "Export Form JSON" button
- Save the JSON file
-
Import to Django:
- Go to http://127.0.0.1:8000/admin/
- Navigate to Forms Builder β Form Definitions
- Click "Add Form Definition"
- Enter a unique ID (e.g., "my-form")
- Enter title and description
- Paste the JSON into the "Definition" field
- Check "Is active"
- Click "Save"
-
View your form:
-
Go to admin:
- Visit http://127.0.0.1:8000/admin/
- Login with your superuser credentials
-
Create a form:
- Navigate to Forms Builder β Form Definitions
- Click "Add Form Definition"
-
Configure the form:
- ID:
my-custom-form(unique identifier) - Title:
My Custom Form - Description: Optional description
- Multi-step: Check if you want multiple steps
- Definition: Paste or write JSON (see example below)
- Is active: Check to make it available
- ID:
-
Example JSON:
{ "id": "my-custom-form", "title": "My Custom Form", "description": "A simple form", "isMultiStep": false, "steps": [{ "id": "step-1", "title": "Information", "order": 0, "fields": [{ "id": "name", "type": "text", "name": "name", "label": "Your Name", "required": true, "validation": [{ "type": "required", "message": "Name is required" }] }] }] } -
View your form:
GET /forms/api/forms/<form_id>/
Example:
curl http://127.0.0.1:8000/forms/api/forms/contact-form/POST /forms/api/forms/<form_id>/submit/
Content-Type: application/json
Example:
curl -X POST http://127.0.0.1:8000/forms/api/forms/contact-form/submit/ \
-H "Content-Type: application/json" \
-d '{"name":"John Doe","email":"john@example.com","message":"Hello!"}'POST /forms/api/forms/<form_id>/validate/
Content-Type: application/json
Example:
curl -X POST http://127.0.0.1:8000/forms/api/forms/contact-form/validate/ \
-H "Content-Type: application/json" \
-d '{"name":"John Doe","email":"john@example.com"}'example-django/
βββ manage.py # Django management script
βββ requirements.txt # Python dependencies
βββ db.sqlite3 # SQLite database (created after migrate)
βββ demo_project/
β βββ __init__.py
β βββ settings.py # Django settings
β βββ urls.py # URL routing
β βββ wsgi.py # WSGI config
β βββ fixtures/
β β βββ example_forms.json # Example form fixtures
β βββ static/
β β βββ forms/ # Frontend component builds (optional)
β βββ templates/
β βββ base.html # Base template
β βββ home.html # Home page
β βββ forms/
β βββ builder.html # Form builder page
β βββ renderer.html # Form renderer page
βββ README.md # This file
A simple single-step contact form with:
- Name field (required, min 2 chars)
- Email field (required, email validation)
- Message textarea (required, min 10 chars)
A three-step registration wizard with:
- Step 1: Personal info (first name, last name, age 18+)
- Step 2: Contact details (email)
- Step 3: Additional info (optional bio)
A two-step customer satisfaction survey with:
- Step 1: Basic information (name, purchase date)
- Step 2: Feedback (rating 1-5, comments)
Edit the templates in demo_project/templates/ to customize the look and feel.
See the main project documentation for adding custom field types to the renderer.
Add custom validation rules in the Django admin or through the API.
Extend the FormSubmissionView in the forms_builder package to send emails on submission.
Make sure you've installed the forms_builder package:
cd packages/backend
pip install -e .Build the frontend components:
cd ../.. # to project root
npm install
npm run build:all- Check that the form is marked as "Is active" in admin
- Verify the form ID in the URL matches the form ID in the database
- Check browser console for JavaScript errors
Delete db.sqlite3 and re-run migrations:
rm db.sqlite3
python manage.py migrate
python manage.py createsuperuser-
Start Simple:
- Load the example forms
- View them in the renderer
- Submit some test data
- View submissions in admin
-
Try the Builder:
- Create a simple form in the builder
- Export and import to Django
- Test it in the renderer
-
Explore Multi-Step:
- Create a multi-step form
- Configure step navigation
- Test the wizard flow
-
Add Conditional Logic:
- Add conditional field visibility
- Test with different user inputs
- See fields show/hide dynamically
-
Customize:
- Modify the templates
- Add custom field types
- Integrate with your app
For questions or issues:
- Check the main project README
- Review the troubleshooting section
- Check the Django admin for validation errors
This example project is part of the Forms POC and is provided as-is for demonstration purposes.