Skip to main content

A CLI tool to bootstrap a production-ready Django REST Framework project in seconds.

Project description

Django Shortcut (django-shortcut)

PyPI version Python versions License: MIT

A powerful, light-weight Command-Line Interface (CLI) tool to bootstrap a production-ready Django REST Framework (DRF) project in seconds.

This tool automates the tedious setup tasks—such as configuring virtual environments, installing dependencies, writing .env files, setting up CORS, and configuring JSON Web Token (JWT) authentication—so you can focus on writing your API endpoints immediately.


🚀 Features

  • 🐍 Automatic Virtual Environment (venv): Installs, configures, and upgrades pip, setuptools, and wheel inside the local environment.
  • 📦 Pre-configured Dependencies: Installs django, djangorestframework, djangorestframework-simplejwt, django-cors-headers, django-environ, and pillow automatically.
  • ⚙️ Production-Ready settings.py: Out-of-the-box support for .env loading, CORS configuration, database connection environment variables, and media/static root configurations.
  • 🔐 Pre-configured JWT Auth: Pre-integrated JWT auth settings using djangorestframework-simplejwt.
  • 🔧 Git Integration: Initializes a Git repository and writes a comprehensive .gitignore file.
  • 🐳 Dependency Locking: Auto-generates a requirements.txt file based on the local virtualenv state.
  • 📚 Tailored Documentation: Generates a project-specific README.md inside your new project folder with instructions to run and scale.

📋 Requirements

  • Python: Version 3.8 or higher
  • Git: Installed and configured (optional, for repository initialization)

⚙️ Installation

Install the package directly from PyPI:

pip install django-shortcut

To verify the installation:

dj-shortcuts --help

🛠️ Usage & Quick Start

Create a new Django REST Framework project using a single command:

dj-shortcuts <project_name>

Examples

Basic Project Initialization:

dj-shortcuts ecommerce_api

Generate Project in a Custom Directory:

dj-shortcuts ecommerce_api --target C:\Projects\ecommerce_api

(or use the shorthand: -t C:\Projects\ecommerce_api)


💡 Alternative Invocation (Windows PATH Troubleshooting)

If you get an error saying 'dj-shortcuts' is not recognized as an internal or external command, it means Python's user scripts folder is not in your system PATH variable.

You can run the generator module directly using Python without changing system variables:

python -m django_shortcuts.cli <project_name>

Example:

python -m django_shortcuts.cli ecommerce_api

📁 Generated Project Structure

When you create a project, the following directory tree is generated:

my_project_name/
├── venv/                 # Python Virtual Environment
├── my_project_name/      # Django Settings Directory
│   ├── __init__.py
│   ├── asgi.py
│   ├── settings.py       # Fully preconfigured DRF/JWT settings
│   ├── urls.py           # Preconfigured with static/media routing
│   └── wsgi.py
├── .env                  # Pre-populated secret key & db environment variables
├── .gitignore            # Complete Python and Django Git excludes
├── manage.py
├── requirements.txt      # Installed dependencies pinned versions
└── README.md             # Running instructions specific to your project

🏃‍♂️ Step-by-Step Post-Creation Guide

Once your project is created, follow these steps to run your development server:

1. Navigate to the project directory

cd ecommerce_api

2. Activate the virtual environment

  • On Windows (PowerShell):
    venv\Scripts\Activate.ps1
    
  • On Windows (CMD):
    venv\Scripts\activate.bat
    
  • On macOS/Linux:
    source venv/bin/activate
    

3. Start the Development Server

python manage.py runserver

Now, visit:

4. Create a Superuser

To log in to the admin panel, create a new administrative user:

python manage.py createsuperuser

🛠️ Local Development & Testing

To run or test django-shortcut on your local system:

  1. Clone this repository:
    git clone https://github.com/imhnoyon/dj-shortcuts.git
    cd dj-shortcuts
    
  2. Install the package in editable mode:
    pip install -e .
    
    Any changes you make to the source code will immediately reflect when you run dj-shortcuts.

📦 How to Publish to PyPI

If you want to package and upload this tool to your own PyPI account:

1. Install Build and Twine

pip install build twine

2. Build the Distribution Archives

Run the builder from the project root (where pyproject.toml is located):

python -m build

This generates a source distribution (.tar.gz) and a built wheel (.whl) inside the dist/ directory.

3. Upload to PyPI

Upload your packaged distribution using Twine:

python -m twine upload dist/*

Enter your PyPI token when prompted.


📄 License

This project is licensed under the MIT License. See the LICENSE file for more information.


👤 Author & Support

Developed with ❤️ by Mahedi Hasan Noyon.

If you find this tool helpful, please give a ⭐️ to the GitHub Repository!

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

django_shortcut-0.1.4.tar.gz (11.1 kB view details)

Uploaded Source

Built Distribution

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

django_shortcut-0.1.4-py3-none-any.whl (15.7 kB view details)

Uploaded Python 3

File details

Details for the file django_shortcut-0.1.4.tar.gz.

File metadata

  • Download URL: django_shortcut-0.1.4.tar.gz
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for django_shortcut-0.1.4.tar.gz
Algorithm Hash digest
SHA256 4c1f5cc8bd64281d762be93b89b4c5d1d40602093c88a8cafa248a877cbe277c
MD5 c064a515c67bcc633d3518cf3668c12c
BLAKE2b-256 ee9f0eff4c9bf4b5b257f43b4d7d20b4b00478c174404f7eb61c55a9b8e1564f

See more details on using hashes here.

File details

Details for the file django_shortcut-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for django_shortcut-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 21c31167e30243e735da34040241345ddb39ea8998cc567fbc5ca15676b87790
MD5 5aed85a6c218d32740714515b4288b76
BLAKE2b-256 a0466e747d4377cb3585bec13d96c3500b0a44c1e7a5b28f8aa7d4db35619918

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