Skip to main content

Advanced Django app creator with customizable architecture templates

Project description

dj-reframe

Advanced Django App Creator with customizable architecture templates.

Description

DjReframe is a Django extension that transforms the standard startapp command. Instead of a generic default structure, DjReframe lets you create applications with specialized architectures (Web, API/DRF, Service Layer, etc.) in seconds. You can use our predefined structures or create your own.

Features

  • ๐Ÿš€ Multiple Architecture Templates: Create Django apps with pre-defined architectures
  • ๐ŸŽจ Custom Templates: Use your own templates by adding them to your user folder
  • ๐Ÿ“ Cross-Platform: Works on Windows, macOS, and Linux
  • ๐Ÿ”ง CLI Interface: Simple command-line interface with clear feedback
  • โœ… Django Validation: Validates app names and prevents common mistakes

Installation

pip install dj-reframe

Or with Poetry:

poetry add dj-reframe

Upgrade

Keep your package up to date with the latest updates

pip install --upgrade dj-reframe

Usage

Basic Usage

Create a new Django app with a specific architecture:

dj-reframe <app_name> <architecture_type>

Examples:

# Create a web app
dj-reframe blog sitev1

# Create a DRF API app
dj-reframe api drf

# Create a WebSocket app
dj-reframe chat websockets

Using Custom Templates

You can create your own templates and use them with DjReframe:

# Open the custom templates folder
dj-reframe --my-templates

This will open the folder where you can add your own architecture templates. Just create a new folder with your template name and add your Django app structure inside it.

๐Ÿ“ Template File Naming Rules

For DjReframe (and Django's startapp) to recognize and properly process your custom templates, all Python files must end with .py-tpl instead of .py.

Why? When Django creates an app from a template, it automatically strips the -tpl suffix. So views.py-tpl becomes views.py in the generated app.

Example of a custom template structure:

my-custom-arch/
โ”œโ”€โ”€ __init__.py-tpl
โ”œโ”€โ”€ admin.py-tpl
โ”œโ”€โ”€ apps.py-tpl
โ”œโ”€โ”€ models.py-tpl
โ”œโ”€โ”€ views.py-tpl
โ”œโ”€โ”€ urls.py-tpl
โ”œโ”€โ”€ migrations/
โ”‚   โ””โ”€โ”€ __init__.py-tpl
โ”œโ”€โ”€ static/
โ”‚   โ””โ”€โ”€ app_name/
โ””โ”€โ”€ templates/
    โ””โ”€โ”€ app_name/

Important:

  • โœ… Python files: MUST use .py-tpl (e.g., models.py-tpl)
  • โœ… Non-Python files: Use normal extensions (e.g., style.css, index.html)
  • โœ… Directories: No special suffix needed (e.g., migrations/, templates/)

Once your template is ready, use it with:

dj-reframe <app_name> my-custom-arch

Available Architectures

Click on each architecture to see its complete structure:

sitev1 - Basic Django web application
sitev1/
โ”œโ”€โ”€ __init__.py
โ”œโ”€โ”€ admin.py
โ”œโ”€โ”€ apps.py
โ”œโ”€โ”€ forms.py
โ”œโ”€โ”€ models.py
โ”œโ”€โ”€ tests.py
โ”œโ”€โ”€ urls.py
โ”œโ”€โ”€ views.py
โ”œโ”€โ”€ migrations/
โ”‚   โ””โ”€โ”€ __init__.py
โ”œโ”€โ”€ static/
โ”‚   โ””โ”€โ”€ app_name/
โ”‚       โ”œโ”€โ”€ css/
โ”‚       โ”‚   โ””โ”€โ”€ style.css
โ”‚       โ””โ”€โ”€ js/
โ”‚           โ””โ”€โ”€ script.js
โ””โ”€โ”€ templates/
    โ””โ”€โ”€ app_name/
        โ””โ”€โ”€ index.html
sitev2 - Django web app with service layer
sitev2/
โ”œโ”€โ”€ __init__.py
โ”œโ”€โ”€ admin.py
โ”œโ”€โ”€ apps.py
โ”œโ”€โ”€ forms.py
โ”œโ”€โ”€ models.py
โ”œโ”€โ”€ selectors.py
โ”œโ”€โ”€ services.py
โ”œโ”€โ”€ urls.py
โ”œโ”€โ”€ views.py
โ”œโ”€โ”€ migrations/
โ”‚   โ””โ”€โ”€ __init__.py
โ”œโ”€โ”€ static/
โ”‚   โ””โ”€โ”€ app_name/
โ”‚       โ”œโ”€โ”€ css/
โ”‚       โ”‚   โ””โ”€โ”€ style.css
โ”‚       โ””โ”€โ”€ js/
โ”‚           โ””โ”€โ”€ script.js
โ”œโ”€โ”€ templates/
โ”‚   โ””โ”€โ”€ app_name/
โ”‚       โ””โ”€โ”€ index.html
โ””โ”€โ”€ tests/
    โ”œโ”€โ”€ __init__.py
    โ”œโ”€โ”€ test_selectors.py
    โ”œโ”€โ”€ test_serices.py
    โ””โ”€โ”€ test_views.py
api - Django REST Framework API
api/
โ”œโ”€โ”€ __init__.py
โ”œโ”€โ”€ admin.py
โ”œโ”€โ”€ apps.py
โ”œโ”€โ”€ forms.py
โ”œโ”€โ”€ models.py
โ”œโ”€โ”€ pagination.py
โ”œโ”€โ”€ permissions.py
โ”œโ”€โ”€ selectors.py
โ”œโ”€โ”€ serializers.py
โ”œโ”€โ”€ services.py
โ”œโ”€โ”€ tests.py
โ”œโ”€โ”€ urls.py
โ”œโ”€โ”€ views.py
โ”œโ”€โ”€ migrations/
โ”‚   โ””โ”€โ”€ __init__.py
โ””โ”€โ”€ tests/
    โ”œโ”€โ”€ __init__.py
    โ”œโ”€โ”€ test_api.py
    โ”œโ”€โ”€ test_selectors.py
    โ”œโ”€โ”€ test_serializers.py
    โ””โ”€โ”€ test_serices.py
api-graphql - GraphQL API with Strawberry/Graphene
api-graphql/
โ”œโ”€โ”€ __init__.py
โ”œโ”€โ”€ admin.py
โ”œโ”€โ”€ apps.py
โ”œโ”€โ”€ inputs.py
โ”œโ”€โ”€ middleware.py
โ”œโ”€โ”€ models.py
โ”œโ”€โ”€ mutations.py
โ”œโ”€โ”€ queries.py
โ”œโ”€โ”€ schema.py
โ”œโ”€โ”€ services.py
โ”œโ”€โ”€ types.py
โ”œโ”€โ”€ urls.py
โ”œโ”€โ”€ utils.py
โ”œโ”€โ”€ migrations/
โ”‚   โ””โ”€โ”€ __init__.py
โ””โ”€โ”€ tests/
    โ”œโ”€โ”€ __init__.py
    โ”œโ”€โ”€ test_mutations.py
    โ”œโ”€โ”€ test_queries.py
    โ”œโ”€โ”€ test_shema.py
    โ””โ”€โ”€ test_types.py
websockets - WebSocket-based application
websockets/
โ”œโ”€โ”€ __init__.py
โ”œโ”€โ”€ admin.py
โ”œโ”€โ”€ apps.py
โ”œโ”€โ”€ auth.py
โ”œโ”€โ”€ consumers.py
โ”œโ”€โ”€ events.py
โ”œโ”€โ”€ exceptions.py
โ”œโ”€โ”€ middleware.py
โ”œโ”€โ”€ models.py
โ”œโ”€โ”€ room.py
โ”œโ”€โ”€ routing.py
โ”œโ”€โ”€ selectors.py
โ”œโ”€โ”€ services.py
โ”œโ”€โ”€ tests.py
โ”œโ”€โ”€ utils.py
โ”œโ”€โ”€ views.py
โ”œโ”€โ”€ migrations/
โ”‚   โ””โ”€โ”€ __init__.py
โ””โ”€โ”€ tests/
    โ”œโ”€โ”€ __init__.py
    โ”œโ”€โ”€ test_consumers.py
    โ”œโ”€โ”€ test_middleware.py
    โ””โ”€โ”€ test_routing.py
service-layer - Service layer pattern
service-layer/
โ”œโ”€โ”€ __init__.py
โ”œโ”€โ”€ admin.py
โ”œโ”€โ”€ apps.py
โ”œโ”€โ”€ models.py
โ”œโ”€โ”€ selectors.py
โ”œโ”€โ”€ services.py
โ”œโ”€โ”€ urls.py
โ”œโ”€โ”€ views.py
โ””โ”€โ”€ migrations/
    โ””โ”€โ”€ __init__.py
celery-tasks - Celery async tasks
celery-tasks/
โ”œโ”€โ”€ __init__.py
โ”œโ”€โ”€ admin.py
โ”œโ”€โ”€ apps.py
โ”œโ”€โ”€ models.py
โ”œโ”€โ”€ tasks.py
โ”œโ”€โ”€ urls.py
โ”œโ”€โ”€ views.py
โ””โ”€โ”€ migrations/
    โ””โ”€โ”€ __init__.py
admin-centric - Django Admin focused
admin-centric/
โ”œโ”€โ”€ __init__.py
โ”œโ”€โ”€ admin.py
โ”œโ”€โ”€ apps.py
โ”œโ”€โ”€ models.py
โ”œโ”€โ”€ urls.py
โ”œโ”€โ”€ views.py
โ””โ”€โ”€ migrations/
    โ””โ”€โ”€ __init__.py
microservice - Lightweight microservice
microservice/
โ”œโ”€โ”€ __init__.py
โ”œโ”€โ”€ admin.py
โ”œโ”€โ”€ apps.py
โ”œโ”€โ”€ models.py
โ”œโ”€โ”€ serializers.py
โ”œโ”€โ”€ urls.py
โ”œโ”€โ”€ views.py
โ””โ”€โ”€ migrations/
    โ””โ”€โ”€ __init__.py
ml-integration - Machine Learning integration
ml-integration/
โ”œโ”€โ”€ __init__.py
โ”œโ”€โ”€ admin.py
โ”œโ”€โ”€ apps.py
โ”œโ”€โ”€ ml_utils.py
โ”œโ”€โ”€ models.py
โ”œโ”€โ”€ urls.py
โ”œโ”€โ”€ views.py
โ””โ”€โ”€ migrations/
    โ””โ”€โ”€ __init__.py

Or create your own custom templates!

Requirements

  • Python >= 3.10
  • Django >= 4.0

Development

Running Tests

pytest tests/

Code Quality

This project uses:

  • Ruff for linting and formatting
  • MyPy for type checking
  • Pre-commit hooks for automated checks

Setup pre-commit hooks:

pre-commit install

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Repository

GitHub: https://github.com/DougVikt/dj-reframe

Issues

If you encounter any issues or have suggestions, please file an issue on the GitHub Issues page.

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

dj_reframe-0.1.0.tar.gz (15.4 kB view details)

Uploaded Source

Built Distribution

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

dj_reframe-0.1.0-py3-none-any.whl (44.9 kB view details)

Uploaded Python 3

File details

Details for the file dj_reframe-0.1.0.tar.gz.

File metadata

  • Download URL: dj_reframe-0.1.0.tar.gz
  • Upload date:
  • Size: 15.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.4 CPython/3.12.13 Linux/6.17.0-1010-azure

File hashes

Hashes for dj_reframe-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0472ed62f8bb9de15818096b8e9ed98d3819aa76fbd421c05f626ad976fa45f3
MD5 cc9d314cad56c23a073c0c28a742b585
BLAKE2b-256 12fb69514d055972257b02d9dad8e098f4fa8e0f9fd1920f53b10d1c7c042166

See more details on using hashes here.

File details

Details for the file dj_reframe-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: dj_reframe-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 44.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.4 CPython/3.12.13 Linux/6.17.0-1010-azure

File hashes

Hashes for dj_reframe-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 41851bc5cb38ca0a907ff5acacf54c0d96a0887579adfacb31bfba86984d8d7e
MD5 187bc49c770b9b7c9cec7aa6d8d25ae9
BLAKE2b-256 c09f967369ce8dcd8a50b16971ae17f1b97490358696233c723a6d1d36128436

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