Skip to main content

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 Banner 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 in INSTALLED_APPS in your project's settings.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: ModelViewSet with standard import.
    • Factory: factory_boy factory 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_api directory is created with the structure defined in simple_drf.
  • The app is automatically added to INSTALLED_APPS in settings.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:

  1. Model: Append class Product(models.Model): ... to core_api/models.py.
  2. Serializer: Create ProductSerializer in core_api/serializers.py with necessary imports.
  3. Views: Create ProductViewSet in core_api/views.py.
  4. URLs: Register ProductViewSet with a router in core_api/urls.py (e.g., router.register(r'products', ProductViewSet)).
  5. Admin: Register Product in core_api/admin.py.
  6. Factories: Create ProductFactory in core_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

dj_cli_tools-0.4.tar.gz (14.7 kB view details)

Uploaded Source

Built Distribution

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

dj_cli_tools-0.4-py3-none-any.whl (17.6 kB view details)

Uploaded Python 3

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

Hashes for dj_cli_tools-0.4.tar.gz
Algorithm Hash digest
SHA256 d1c23b65e6e7da2538bb74e35944d09bbbed81ae1d6fa8f5d1a794a4bce96452
MD5 0466c80edcec04b8360077a91b3f3bec
BLAKE2b-256 8041272b608105e78c01b23cb986b178c9340dc46833289457ad7843360b7329

See more details on using hashes here.

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

Hashes for dj_cli_tools-0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 b9334e0102b0f69eece486db760cc299787802887e1038d5b62949c6827e48b3
MD5 ec230f904fd3f9970e5a03af11658fb7
BLAKE2b-256 0a9c094d70315c6d3b72d5c5b323f68c9a5f66b758c6dd4ac9a18bf3cde0ecb4

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