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.18.tar.gz (19.2 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.18-py3-none-any.whl (27.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: django_model_suite-0.1.18.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

Hashes for django_model_suite-0.1.18.tar.gz
Algorithm Hash digest
SHA256 ef4e46d1832bb4cd1616b668adc1bf6446ab0cf26065f6697a0fce6d96ce6be8
MD5 cd8cea61219c1109053b06f6472eaac0
BLAKE2b-256 bd2e6dfe6189d5c748ad3f191d3a60d830653abc3e1db7ba9bae936a79eec71a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_model_suite-0.1.18-py3-none-any.whl
Algorithm Hash digest
SHA256 5bf7f2c239a1112cded7d2fabf96db046561485ce3ff17869e71171963164148
MD5 596187d27b18178aa55c91e10df1bde0
BLAKE2b-256 f3b35d626fee9c10123499ad5f55e9dc80ea0812fd9313c85fe75f61807f22f8

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