Skip to main content

A Django app for generating boilerplate code

Project description

Django Model Suite

PyPI version License: MIT

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 files
  • domain: Domain logic files (selectors, services, validators)
  • api: REST API files

You can also specify individual components:

  • fields: Field definitions
  • selectors: Query selectors
  • services: Business logic services
  • validators: 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_model_suite-0.1.19.tar.gz (19.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_model_suite-0.1.19-py3-none-any.whl (27.9 kB view details)

Uploaded Python 3

File details

Details for the file django_model_suite-0.1.19.tar.gz.

File metadata

  • Download URL: django_model_suite-0.1.19.tar.gz
  • Upload date:
  • Size: 19.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for django_model_suite-0.1.19.tar.gz
Algorithm Hash digest
SHA256 6b4d342d262814e04e667e60940925715070e3442a620bb989c71e0618358eb9
MD5 c775079bc8fcd19198ac2a76f7519f45
BLAKE2b-256 601514cbd5dffab3990b2c55620ab8c872db9be8ad57c8f2030841d050566a8a

See more details on using hashes here.

File details

Details for the file django_model_suite-0.1.19-py3-none-any.whl.

File metadata

File hashes

Hashes for django_model_suite-0.1.19-py3-none-any.whl
Algorithm Hash digest
SHA256 cafee8c307a680beb463851febf7d3930a35a4edeb767fc61874a77df0696b3c
MD5 7cddf8f652446aa8d34f82afe1192572
BLAKE2b-256 372732b6bbd55986206da6ead2964de2ecd99e79ffa50ed01cdd55da91b1da35

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page