A Django app for generating boilerplate code
Project description
Django Model Suite
A comprehensive Django package that automatically generates standardized boilerplate code for your Django models following domain-driven design principles and best practices.
Overview
Django Model Suite eliminates repetitive coding tasks by generating a complete suite of files for each model in your Django application. With a single command, you can create a fully-functional architecture including:
- Admin Interface: List views, change views, permissions, context providers, display configurations, and resources
- REST API: Serializers, views, URL configurations, filters, and pagination
- Domain Logic: Selectors, services, and validators
- Field Definitions: Clean field organization and management
Features
- One Command, Many Files: Generate dozens of boilerplate files with a single command
- Best Practices Baked In: Follow domain-driven design and architectural best practices automatically
- DRF Integration: Complete REST API scaffolding with Django Rest Framework
- Django Unfold Support: Built-in support for the modern Django Unfold admin theme
- Customizable: Generate only the components you need
- Clean Architecture: Promotes separation of concerns and maintainable code structure
- Time-Saving: Eliminate hours of repetitive coding for each model
Installation
pip install django-model-suite
Then add it to your INSTALLED_APPS in settings.py:
INSTALLED_APPS = [
# ...
'django_model_suite',
# ...
]
Requirements
- Python 3.8+
- Django 5.0+
- Django Unfold 0.45.0+
- Django Rest Framework 3.14.0+
- Django Filter 23.0+
Usage
Basic Usage
Generate all components for a model with a single command:
python manage.py generate_files <app_name> <model_name>
Example:
python manage.py generate_files users customer
Selective Generation
Generate only specific components:
python manage.py generate_files <app_name> <model_name> --components admin api
Available component groups:
admin: Admin interface filesdomain: Domain logic files (selectors, services, validators)api: REST API files
You can also specify individual components:
fields: Field definitionsselectors: Query selectorsservices: Business logic servicesvalidators: Data validation
Configuration
Customize the package behavior in your project's settings.py:
# Custom path for BaseModelAdmin (default: 'django_model_suite.admin')
BASE_MODEL_ADMIN_PATH = 'your_app.admin'
Generated Structure
After running the command, your app will have the following structure:
your_app/
│
├─ fields/
│ └─ <model_name>.py # Field definitions
│
├─ admin/
│ └─ <model_name>/
│ ├─ __init__.py # Package initialization
│ ├─ admin.py # Main Admin registration
│ ├─ change_view.py # Change view configuration
│ ├─ context.py # Context data providers
│ ├─ display.py # Display configuration
│ ├─ inline.py # Inline model configuration
│ ├─ list_view.py # List view configuration
│ ├─ permissions.py # Permission handling
│ └─ resource.py # Resource configuration
│
├─ api/
│ └─ <model_name>/
│ ├─ __init__.py # Package initialization
│ ├─ filters.py # API filtering options
│ ├─ pagination.py # Custom pagination settings
│ ├─ serializers.py # DRF serializers
│ ├─ urls.py # API URL routing
│ └─ views.py # API views and viewsets
│
└─ domain/
├─ selectors/
│ └─ <model_name>.py # Query logic
├─ services/
│ └─ <model_name>.py # Business logic
└─ validators/
└─ <model_name>.py # Validation logic
Benefits
- Consistency: Maintain a consistent code structure across your entire project
- Productivity: Focus on business logic rather than boilerplate code
- Maintainability: Cleanly organized code following best practices
- Scalability: Architecture designed to support project growth
- Onboarding: Easier onboarding for new developers with consistent patterns
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Author
Omar Gawdat - GitHub
Project details
Release history Release notifications | RSS feed
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 django_model_suite-0.2.0.tar.gz.
File metadata
- Download URL: django_model_suite-0.2.0.tar.gz
- Upload date:
- Size: 19.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
da13aab6d8be2d9d1ea550d8afdef98db81bef85ed85da652f198e2f85a8a4e3
|
|
| MD5 |
26e6f4375650adda072513be20639160
|
|
| BLAKE2b-256 |
e23c9b5575f9a2f6cfd2055f308e3700c75ca9d1d3d9425266ae68aa5686eac8
|
File details
Details for the file django_model_suite-0.2.0-py3-none-any.whl.
File metadata
- Download URL: django_model_suite-0.2.0-py3-none-any.whl
- Upload date:
- Size: 27.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
21b2abed3dd53ca10cfcf0317941a5d69aa68c672fecac9e27767e11576acc1a
|
|
| MD5 |
af951a0edc228f8a45119b5ff6f55905
|
|
| BLAKE2b-256 |
cdb5507b089fdd226f8b9676f45224b4092596b94353b869183884e702aa3bff
|