A CLI tool for generating Django project boilerplates with customizable structures, flexible directory layouts, and built-in support for common services like Docker, Celery, and Redis.
- Flexible Project Structures - Place apps anywhere: root level, nested directories, or custom layouts
- Multiple App Types - Standard, REST API, and Authentication apps with appropriate files
- Service Integration - Built-in support for Docker, Celery, Redis, and more
- Template-Based Generation - Jinja2 templates for easy customization
- Configuration-Driven - Use YAML configs for reproducible project setups
- Interactive Mode - User-friendly CLI for step-by-step project creation
- Automatic Dependencies - Generates requirements.txt with all needed packages
# Clone the repository
git clone https://github.com/munjed-ab/djcraft.git
# Install dependencies
poetry install
poetry shellcd djcraft
python main.py interactiveFollow the prompts to create your project structure.
# Basic project with apps at root level
python main.py create myproject --apps blog users --core-location root
# Project with nested structure
python main.py create myproject --apps blog users api --directory apps --core-location custom --core-path config
# Add services
python main.py create myproject --apps blog --docker --celery --redisCreate a project_config.yaml:
project_name: my_blog
# Core Django files location
core:
location: root # or 'custom'
path: core # if custom, specify path
# Define custom directories
directories:
- name: apps
parent: ""
- name: api
parent: apps
# Define Django apps
apps:
- name: blog
path: apps/blog
- name: users
path: apps/users
- name: posts_api
path: api/posts_api
# Services to include
services:
- name: docker
options:
python_version: "3.11"
postgres_version: "15"
- name: celery
options:
broker: redis
use_flower: true
- name: redis
options:
use_for_cache: true
use_for_sessions: true
- name: rest_api
options:
framework: drfThen generate:
python main.py generate project_config.yamlpython main.py create PROJECT_NAME [OPTIONS]
Options:
--apps APP1 APP2 ... List of Django apps to create
--directory DIR Place apps in this directory
--core-location {root,custom} Where to place core Django files
--core-path PATH Path for core files (if custom)
--docker Include Docker configuration
--celery Include Celery configuration
--redis Include Redis configuration
--rest-api Include Django REST Framework
--db-router Include database routerpython main.py interactiveGuided interface for creating projects with all configuration options.
python main.py generate CONFIG_FILE.yamlpython main.py validate CONFIG_FILE.yamlCheck your configuration file for errors before generation.
Default Django app with models, views, admin, urls.
# Auto-detected for most app names
python main.py create myproject --apps blog productsIncludes serializers and API views for REST endpoints.
# Auto-detected for apps with 'api' in the name
python main.py create myproject --apps blog_api users_apiIncludes custom user models and authentication forms.
# Auto-detected for apps named: users, accounts, auth, authentication
python main.py create myproject --apps usersGenerates Dockerfile and docker-compose.yml with PostgreSQL, Redis, and your Django app.
services:
- name: docker
options:
python_version: "3.11"
postgres_version: "15"Configures Celery for asynchronous task processing.
services:
- name: celery
options:
broker: redis # or 'rabbitmq'
use_flower: true # Celery monitoring toolSets up Redis for caching and sessions.
services:
- name: redis
options:
use_for_cache: true
use_for_sessions: true
host: redis
port: 6379Configures Django REST Framework.
services:
- name: rest_api
options:
framework: drfThe generator uses a layered configuration approach:
- Default Settings (
core/config.py) - Base configuration - Runtime Config (
core/runtime_config.py) - YAML overrides - Configuration Manager (
core/configuration_manager.py) - Merges all configs
- Check that templates exist in
templates/app_template/ - Verify configuration is properly loaded
- Run with
--verboseflag for detailed output - Check file permissions in output directory
- Ensure Jinja2 is installed:
pip install jinja2 - Check template syntax in
.templatefiles - Verify context variables match template expectations
Some services require others:
- Celery requires Redis (or RabbitMQ)
- Docker can include Redis and PostgreSQL automatically
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
This project is licensed under the MIT License.
- Django project for the amazing framework
- Jinja2 for powerful templating
- Rich library for beautiful CLI output
Built for internal team use at Eleva