A full-stack form builder application built with Django and React using FormEngine (React Form Builder). This application allows users to create dynamic forms using a visual form builder interface, save them to a database, and render them for end users.
- Visual Form Builder: Drag-and-drop interface powered by FormEngine
- Inline Form Naming: Click-to-edit form names with real-time updates
- Form Management: Save, update, and manage form schemas with ID-based storage
- Form Viewer: Built-in form renderer for displaying forms to end users
- RESTful API: Complete API for form CRUD operations
- Admin Interface: Django admin interface for managing forms
- URL-based Form Loading: Load forms by ID through URL parameters
- Schema Compatibility: Handles both legacy and modern form schemas
- Backend: Django 4.2+ with Django REST Framework
- Frontend: React 18+ with FormEngine (React Form Builder)
- Form Engine: Professional form builder with drag-and-drop interface
- Storage: ID-based form storage with real-time name updates
- Styling: Custom CSS with responsive design
- Database: SQLite (development) / PostgreSQL (production ready)
- ✅ Inline Form Naming: Click-to-edit form names with auto-save
- ✅ Form Viewer: Built-in form renderer for end users
- ✅ URL-based Loading: Load forms by ID through URL parameters
- ✅ Schema Migration: Automatic handling of legacy form schemas
- ✅ Clean Interface: Removed unnecessary statistics cards
- ✅ FormEngine Integration: Full integration with professional form builder
- ✅ Real-time Updates: Form names sync with form saves automatically
django_form_builder/
├── django_form_builder/ # Django project settings
│ ├── settings/ # Environment-specific settings
│ └── urls.py # Main URL configuration
├── formbuilder/ # Main Django app
│ ├── models.py # Form model (FormSubmission removed)
│ ├── views.py # Views for forms, builder, and viewer
│ ├── urls.py # App URL configuration
│ ├── admin.py # Django admin configuration
│ ├── templates/ # HTML templates
│ │ ├── form_builder.html # Form builder interface
│ │ ├── form_view.html # Form viewer interface
│ │ ├── forms_list.html # Forms list page
│ │ └── form_detail.html # Form detail page
│ └── static/css/ # CSS stylesheets
├── frontend/ # React frontend
│ ├── src/
│ │ ├── App.jsx # Main React component with routing
│ │ ├── components/
│ │ │ ├── FormBuilder.jsx # Form builder component
│ │ │ ├── FormViewer.jsx # Form viewer component
│ │ │ └── FormNameEditor.jsx # Inline form name editor
│ │ ├── services/
│ │ │ ├── api.js # API service layer
│ │ │ └── formStorage.js # FormEngine storage implementation
│ │ ├── config.js # Configuration settings
│ │ └── constants/styles.js # Style constants
│ └── package.json # Frontend dependencies
└── requirements.txt # Python dependencies
- Python 3.8+
- Node.js 16+
- npm or yarn
-
Install Python dependencies:
pip install -r requirements.txt
-
Run database migrations:
python manage.py makemigrations python manage.py migrate
-
Create a superuser (optional):
python manage.py createsuperuser
-
Start the Django development server:
python manage.py runserver
The Django server will be available at http://localhost:8000
The frontend is automatically built and served by Django's runserver
command, so no additional setup is required for basic usage.
For development and debugging:
-
Navigate to the frontend directory:
cd frontend
-
Install dependencies:
npm install
-
Start the development server (optional):
npm run dev
This will start the Vite development server at
http://localhost:5173
with hot reloading for debugging and development work.
Note: The Django server (python manage.py runserver
) automatically handles the frontend build files, so the React app is accessible through Django at http://localhost:8000
. Use npm run dev
only if you need the development server features like hot reloading.
GET /formbuilder/
- Form builder interface (new form)GET /formbuilder/{id}/
- Form builder interface (edit existing form)GET /formbuilder/{id}/view/
- Form viewer interface (render form)GET /formbuilder/forms/
- Forms list pageGET /formbuilder/forms/{id}/
- Form detail page
GET /formbuilder/api/forms/
- Get all formsGET /formbuilder/api/forms/{id}/
- Get specific formPOST /formbuilder/api/forms/
- Create new formPUT /formbuilder/api/forms/{id}/
- Update formDELETE /formbuilder/api/forms/{id}/
- Delete form
- Navigate to
http://localhost:8000/formbuilder/
(new form) orhttp://localhost:8000/formbuilder/{id}/
(edit existing) - Click on the form name at the top to edit it inline
- Drag and drop form components from the left panel
- Configure component properties in the right panel
- The form automatically saves as you work
- Navigate to
http://localhost:8000/formbuilder/{id}/view/
to see the rendered form - The form displays exactly as end users would see it
- Form validation and submission handling are built-in
- Access the forms list at
http://localhost:8000/formbuilder/forms/
- View form details, edit, or delete forms
- Access the Django admin interface at
http://localhost:8000/admin/
for advanced management
Run the included test script to verify API functionality:
python test_api.py
This script will test all API endpoints and verify that forms can be created, retrieved, updated, and deleted.
- Start the Django server:
python manage.py runserver
- Navigate to
http://localhost:8000/formbuilder/
to create a new form - Edit the form name by clicking on it
- Add form components using the drag-and-drop interface
- Navigate to
http://localhost:8000/formbuilder/forms/
to see your forms - Click "View Form" to see the rendered form
- Click "Edit" to modify the form
- Check the Django admin at
http://localhost:8000/admin/
to verify data
name
: Form name (CharField, max_length=255)schema
: Form schema in JSON format (JSONField)created
: Creation timestamp (DateTimeField, auto-created)modified
: Last update timestamp (DateTimeField, auto-updated)is_active
: Whether the form is active (BooleanField, default=True)
get_component_count()
: Returns the number of components in the formget_component_types()
: Returns a list of component types used in the formget_schema()
: Returns the schema as a Python object
The frontend configuration is managed in frontend/src/config.js
:
API_BASE_URL
: Base URL for API requests (default: http://localhost:8000)API_ENDPOINTS
: Endpoint definitions for all API callsDEFAULT_HEADERS
: Default HTTP headers for API requests
You can override the API base URL using environment variables:
VITE_API_BASE_URL=http://your-api-server.com npm run dev
- CORS Errors: Make sure
django-cors-headers
is installed and configured - API Connection Issues: Verify the API_BASE_URL in frontend config
- Database Issues: Run migrations if you see database-related errors
- Port Conflicts: Make sure ports 8000 (Django) and 5173 (React) are available
Enable debug logging in the frontend by setting:
VITE_DEBUG=true npm run dev
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is licensed under the MIT License.