A lightweight Django project generator for rapid scaffolding of apps, models, and templates. Ideal for developers seeking to streamline Django setup and code generation.
Project description
๐ DJ Maker - Supercharge Your Django Development
Rapidly generate Django apps, models, views, URLs, and templates with a single command.
DJ Maker is a powerful code generation tool that accelerates Django development by automatically creating complete CRUD applications, API endpoints, and boilerplate code. Say goodbye to repetitive tasks and hello to productive development! โก
โจ Features
๐๏ธ Complete App Generation
- Full CRUD Apps: Generate complete Django applications with models, views, URLs, and templates
- Multiple View Types: Support for function-based views, class-based views, and DRF API views
- Smart Templates: Beautiful, responsive HTML templates with Bootstrap styling
- Advanced URL Patterns: Nested URLs, namespacing, and API versioning support
๐ฏ Developer Experience
- Rich CLI Interface: Beautiful, colored terminal output powered by Rich
- Interactive Prompts: Guided setup with intelligent defaults
- Preview Mode: See what will be generated before creating files
- Type Safety: Full type annotations and mypy support
๐ง Flexibility & Power
- API-First Development: Generate Django REST Framework endpoints automatically
- Custom Namespacing: Support for API versioning and modular architectures
- Template Customization: Jinja2-powered templates with extensibility
- Project Integration: Seamlessly integrates with existing Django projects
๐ Quick Start
Installation
pip install dj-maker
Create Your First Project
# Create a new Django project with best practices
dj init myblog
# Navigate to your project
cd myblog
Generate Your First App
# Create a complete blog app with CRUD operations
dj generate blog Post --view-type=class
# Generate an API-first app with DRF integration
dj generate api articles Article --view-type=api --namespace=v1
# Create function-based views for maximum control
dj generate shop Product --view-type=function
Initialize Apps in Existing Projects
# Create a new Django app with URLs and tests
dj init-app users
# Create app with specific URL template
dj init-app api --url-template=api --include-tests
๐ Usage Examples
๐จ Basic CRUD Generation
Generate a complete blog application with class-based views:
dj generate blog Post --view-type=class
Generated structure:
blog/
โโโ __init__.py
โโโ admin.py # Admin interface with list_display, filters
โโโ apps.py
โโโ models.py # Post model with common fields (title, description, timestamps)
โโโ views.py # Complete CRUD class-based views
โโโ urls.py # RESTful URL patterns
โโโ templates/blog/ # Bootstrap-styled templates
โ โโโ base.html
โ โโโ post_list.html
โ โโโ post_detail.html
โ โโโ post_form.html
โ โโโ post_confirm_delete.html
โโโ migrations/
๐ API Development
Create a REST API with Django REST Framework:
dj generate api products Product --view-type=api --namespace=v1
Features:
- ViewSets and Serializers
- Router-based URL configuration
- API versioning support
- Both API and web views
๐๏ธ Advanced URL Patterns
Generate nested URL structures:
dj generate articles Article --view-type=advanced
Generated URLs:
urlpatterns = [
path('', views.ArticleListView.as_view(), name='article-list'),
path('create/', views.ArticleCreateView.as_view(), name='article-create'),
path('<int:pk>/', include([
path('', views.ArticleDetailView.as_view(), name='article-detail'),
path('edit/', views.ArticleUpdateView.as_view(), name='article-update'),
path('delete/', views.ArticleDeleteView.as_view(), name='article-delete'),
])),
path('search/', views.ArticleSearchView.as_view(), name='article-search'),
path('export/', views.ArticleExportView.as_view(), name='article-export'),
]
๐ API Versioning
Create versioned APIs for scalable applications:
# Generate v1 API
dj generate api users User --namespace=api_v1 --view-type=api
# Generate v2 API (in separate app)
dj generate api_v2 users User --namespace=api_v2 --view-type=api
URL Structure:
/api/v1/users/ # api_v1:user-list
/api/v1/users/1/ # api_v1:user-detail
/api/v2/users/ # api_v2:user-list
/api/v2/users/1/ # api_v2:user-detail
๐จ Generated Templates
Django CLI creates beautiful, responsive templates using Bootstrap 5:
๐ List View Template
<!-- Responsive table with search, pagination, and actions -->
<div class="container">
<div class="d-flex justify-content-between align-items-center mb-4">
<h1>Posts</h1>
<a href="{% url 'blog:post-create' %}" class="btn btn-primary">
<i class="fas fa-plus"></i> New Post
</a>
</div>
<!-- ... responsive table with Bootstrap styling ... -->
</div>
๐ Form Template
<!-- Modern form with validation and UX enhancements -->
<form method="post" class="needs-validation" novalidate>
{% csrf_token %}
{{ form }}
<div class="mt-3">
<button type="submit" class="btn btn-primary">Save</button>
<a href="{% url 'blog:post-list' %}" class="btn btn-secondary">Cancel</a>
</div>
</form>
๐ง Command Reference
Project Management
dj init <project_name> # Create new Django project
dj init-app <app_name> # Initialize new app
Generation Commands
dj generate <app> <model> [options]
Options:
--view-type [function|class|api|advanced] View type (default: class)
--namespace TEXT URL namespace for versioning
--dry-run Preview files without creating
--no-templates Skip HTML template generation
--help Show help message
URL Management
dj urls create <app_name> # Create urls.py for an app
dj urls list # List apps and their URL status
dj urls check <app_name> # Check specific app's URLs
Utility Commands
dj list-models [app_name] # List models in project/app
dj --version # Show version information
dj --help # Show all available commands
๐ ๏ธ Integration
Add to Existing Projects
- Install dj-maker in your project environment
- Generate new apps directly in your existing project
- Update main URLs manually or let dj suggest the integration:
# Add to your main urls.py
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('blog/', include('blog.urls')), # Generated app
path('api/v1/', include('api.urls')), # Generated API
]
Settings Integration
Django CLI works with your existing Django settings. For API apps, ensure you have DRF configured:
# settings.py
INSTALLED_APPS = [
# ... your apps
'rest_framework',
'blog', # Generated app
]
REST_FRAMEWORK = {
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
'PAGE_SIZE': 20
}
๐งช Quality Assurance
- ๐ฏ 92% Test Coverage across all modules
- โ 128 Comprehensive Tests covering all functionality
- ๐ Type Safety with full mypy support
- ๐ Production Ready with comprehensive error handling
- ๐ Well Documented with extensive examples
Test Coverage by Module:
- URLs Generator: 100% - Perfect coverage
- Models Generator: 99% - Near perfect
- Views Generator: 92% - Excellent
- Templates Generator: 89% - Very good
- Main CLI: 89% - Excellent
- Core Package: 100% - Perfect
๐ค Contributing
We welcome contributions! Here's how to get started:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Run tests:
pytest tests/ --cov=src/ - Submit a pull request
Development Setup
git clone https://github.com/giacomo/dj-maker.git
cd dj-maker
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
pip install -e ".[dev]"
pytest
๐ Requirements
- Python: 3.10+
- Django: 4.2, 5.1, 5.2
- Dependencies: Automatically managed via pip
๐บ๏ธ Roadmap
- Template Customization: Custom template directories
- Model Field Inference: Smart field type detection
- Migration Generation: Automatic migration creation
- Testing Generation: Auto-generate test cases
- Docker Integration: Container-ready project setup
- GraphQL Support: Generate GraphQL schemas
๐ Issues & Support
- Bug Reports: GitHub Issues
- Feature Requests: GitHub Discussions
- Documentation: Wiki
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Acknowledgments
- Django community for the amazing framework
- Typer for the excellent CLI framework
- Rich for beautiful terminal output
- Jinja2 for powerful templating
Made with โค๏ธ by Giacomo
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dj_maker-0.2.0.tar.gz.
File metadata
- Download URL: dj_maker-0.2.0.tar.gz
- Upload date:
- Size: 57.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b14928c9add207889ec42eb7b4b27a0746877f4eac88eef09e146d473db4e76d
|
|
| MD5 |
4ab61c404b343e056b22cc7dbf04b29b
|
|
| BLAKE2b-256 |
7bbfd37dacd04a0179b8615445c6866598dc8c2c2e1a6bc5b334f5ce27cbfee6
|
File details
Details for the file dj_maker-0.2.0-py3-none-any.whl.
File metadata
- Download URL: dj_maker-0.2.0-py3-none-any.whl
- Upload date:
- Size: 30.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f5024011fcbd28aab50e71be413ac47a93aad6185cb47fb24854c6c08cb4b569
|
|
| MD5 |
7c04916f9f73b8eb2d8fb2335e4f35a4
|
|
| BLAKE2b-256 |
16f97280ec5fe71da8d0e4138dacad0417be9d0f497f3379fb20475d3501c333
|