dj-cli-tools is a command-line utility for Django developers designed to streamline the process of creating applications and managing boilerplate code.
Project description
dj-cli-tools
dj-cli-tools is a command-line utility for Django developers designed to streamline the process of creating applications and managing boilerplate code. It extends Django's built-in management commands to provide enhanced scaffolding capabilities, particularly focused on Django REST Framework (DRF) workflows.
Features
- Enhanced
start_app: Create new Django applications using custom, pre-configured templates (e.g., versioned REST API structures). Automatically registers the new app inINSTALLED_APPSin your project'ssettings.py. create: A powerhouse command that generates a fully functional vertical slice for a new resource. One command creates:- Model: Custom model definition.
- Serializer: Corresponding
ModelSerializer. - ViewSet:
ModelViewSetwith standard import. - Factory:
factory_boyfactory for testing. - Admin: Registers the model in
admin.py. - URLs: Registers the ViewSet in
urls.py.
Installation
pip install dj-cli-tools
Or for local development:
git clone https://github.com/AbhijithKonnayil/dj-cli-tools
cd dj-cli-tools
pip install .
Usage
1. Starting a New App
Create a new app using a specific template. This command acts like startapp but better:
python manage.py start_app <app_name> --dj_template <template_name>
Example: To create a REST API app:
python manage.py start_app core_api --dj_template simple_drf
What happens?
- The
core_apidirectory is created with the structure defined insimple_drf. - The app is automatically added to
INSTALLED_APPSinsettings.py(e.g.,'core_api.apps.CoreApiConfig').
2. Creating a Resource (Model, API, & More)
Generate the full stack for a new domain model in an existing app.
python manage.py create <app_name> <ModelName>
Example:
python manage.py create core_api Product
What happens? This single command will:
- Model: Append
class Product(models.Model): ...tocore_api/models.py. - Serializer: Create
ProductSerializerincore_api/serializers.pywith necessary imports. - Views: Create
ProductViewSetincore_api/views.py. - URLs: Register
ProductViewSetwith a router incore_api/urls.py(e.g.,router.register(r'products', ProductViewSet)). - Admin: Register
Productincore_api/admin.py. - Factories: Create
ProductFactoryincore_api/factories.py.
Requirements
- Python 3.10+
- Django 5.2+
License
BSD-3-Clause
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
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_cli_tools-0.4.tar.gz.
File metadata
- Download URL: dj_cli_tools-0.4.tar.gz
- Upload date:
- Size: 14.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d1c23b65e6e7da2538bb74e35944d09bbbed81ae1d6fa8f5d1a794a4bce96452
|
|
| MD5 |
0466c80edcec04b8360077a91b3f3bec
|
|
| BLAKE2b-256 |
8041272b608105e78c01b23cb986b178c9340dc46833289457ad7843360b7329
|
File details
Details for the file dj_cli_tools-0.4-py3-none-any.whl.
File metadata
- Download URL: dj_cli_tools-0.4-py3-none-any.whl
- Upload date:
- Size: 17.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b9334e0102b0f69eece486db760cc299787802887e1038d5b62949c6827e48b3
|
|
| MD5 |
ec230f904fd3f9970e5a03af11658fb7
|
|
| BLAKE2b-256 |
0a9c094d70315c6d3b72d5c5b323f68c9a5f66b758c6dd4ac9a18bf3cde0ecb4
|