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
Release files for dj-cli-tools 0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| dj_cli_tools-0.4.tar.gz | 14.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| dj_cli_tools-0.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 32.3 kB
Release files / dj_cli_tools-0.4.tar.gz
| Download URL | dj_cli_tools-0.4.tar.gz |
|---|---|
| Size | 14.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d1c23b65e6e7da2538bb74e35944d09bbbed81ae1d6fa8f5d1a794a4bce96452
|
|
BLAKE2b-256 checksum How to use checksums |
8041272b608105e78c01b23cb986b178c9340dc46833289457ad7843360b7329
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.8
|
Release files / dj_cli_tools-0.4-py3-none-any.whl
| Download URL | dj_cli_tools-0.4-py3-none-any.whl |
|---|---|
| Size | 17.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b9334e0102b0f69eece486db760cc299787802887e1038d5b62949c6827e48b3
|
|
BLAKE2b-256 checksum How to use checksums |
0a9c094d70315c6d3b72d5c5b323f68c9a5f66b758c6dd4ac9a18bf3cde0ecb4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.8
|