AppGen: Application Generator Guide
SDCStudio provides a powerful AppGen feature that allows you to generate standalone, production-ready Django applications directly from your SDC4 Data Models.
Overview
With AppGen, you can design your data structure visually in SDCStudio and then instantly generate a fully functional web application that includes:
- Database Models: Automatically mapped from your DM components.
- Forms: Auto-generated forms with validation and Bootstrap styling.
- Views & URLs: Complete CRUD (Create, Read, Update, Delete) interface.
- Templates: Responsive, mobile-friendly HTML templates.
- Docker Support: Ready-to-run Docker configuration.
- XML Support: Automatic generation of SDC-compliant XML instances.
- Validation: Integrated SDC validation using the XML Catalog.
Prerequisites
To use AppGen, the following conditions must be met:
- Creator Access: You must be the creator of the Data Model.
- Published Model: The Data Model must be Published (Generated).
How to Use
1. Create a Data Model
- Navigate to the Data Models section in SDCStudio.
- Create a new Data Model or open an existing one.
- Add components to define your data structure:
- Input: Maps to
CharField - Textarea: Maps to
TextField - Checkbox: Maps to
BooleanField - Integer: Maps to
IntegerField - Dropdown/Radio: Maps to fields with choices
- Input: Maps to
2. Generate the App
- Once your DM is ready and Published, navigate to the Data Model Details page.
- Scroll down to the Downloads section or look for the toolbar.
- Click the Generate App button (rocket icon).
- Wait for the generation process to complete.
- A ZIP file containing your application will be downloaded automatically.
3. Run the Generated App
-
Extract the ZIP file:
bash unzip my_app.zip cd my_app -
Run with Docker (Recommended):
bash docker compose up --buildAccess the app athttp://localhost:8000. -
Run Locally (Manual): ```bash # Create virtual environment python -m venv venv source venv/bin/activate # or venv\Scripts\activate on Windows
Install dependencies
pip install -r requirements.txt
Run migrations
python manage.py migrate
Create superuser (for admin access)
python manage.py createsuperuser
Start server
python manage.py runserver ```
Generated Application Structure
The generated application follows standard Django best practices:
my_app/
├── app/ # Main application logic
│ ├── migrations/ # Database migrations
│ ├── templates/ # HTML templates
│ ├── admin.py # Admin interface config
│ ├── forms.py # Generated forms
│ ├── models.py # Generated database models
│ ├── urls.py # App-specific URLs
│ └── views.py # Class-based views
├── my_app/ # Project configuration
│ ├── settings.py # Django settings
│ └── urls.py # Main URL routing
├── Dockerfile # Docker build instructions
├── docker-compose.yml # Docker Compose config
├── manage.py # Django management script
└── requirements.txt # Python dependencies
Current Limitations
- Cardinality: Currently, repeating components (lists) are not fully supported in the generated forms. This is planned for a future update.
- Authentication: The generated app comes with basic Django authentication support but requires superuser creation for admin access.
Troubleshooting
- "Data model not found": Ensure your DM is saved and published.
- Docker errors: Make sure Docker Desktop is running.
- Database errors: If running locally without Docker, ensure you have configured a database in
settings.py(defaults to SQLite).