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.2.0.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.2.0-py3-none-any.whl (27.5 kB view details)

Uploaded Python 3

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

Hashes for django_model_suite-0.2.0.tar.gz
Algorithm Hash digest
SHA256 da13aab6d8be2d9d1ea550d8afdef98db81bef85ed85da652f198e2f85a8a4e3
MD5 26e6f4375650adda072513be20639160
BLAKE2b-256 e23c9b5575f9a2f6cfd2055f308e3700c75ca9d1d3d9425266ae68aa5686eac8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_model_suite-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 21b2abed3dd53ca10cfcf0317941a5d69aa68c672fecac9e27767e11576acc1a
MD5 af951a0edc228f8a45119b5ff6f55905
BLAKE2b-256 cdb5507b089fdd226f8b9676f45224b4092596b94353b869183884e702aa3bff

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