Skip to main content

A CLI tool to bootstrap Django REST Framework projects quickly and easily.

Project description

DRFGen CLI

PyPI Version
Python Versions

DRFGen is a powerful and interactive CLI tool to quickly bootstrap Django REST Framework projects with best practices and customizable options. It helps you create a ready-to-use DRF project with authentication, API versioning, swagger integration, and more — saving you hours of manual setup.


Features

  • Interactive prompt-based project creation (Django version, DRF, database, auth method, etc.)
  • Virtual environment setup and package installation automation
  • Supports multiple Django versions and DRF versions
  • Choice of authentication methods including JWT and OAuth2
  • Configurable settings structure (simple or advanced with .env)
  • Automatic API versioning support
  • Integration with swagger tools (drf-spectacular or drf-yasg) for API documentation
  • Default common Django packages installed and configured
  • Generates a requirements.txt file automatically
  • Saves project configuration in drfgen_config.json for easy reference
  • Custom Django management command drfgen_startapp to create Django apps tailored to your project settings — automatically adds the app to INSTALLED_APPS and applies your custom templates
  • Dockerize support (optional) (commented out in current version)

Installation

You can install DRFGen from PyPI using pip:

pip install drfgen

Usage

After installation, you get the drfgen CLI command:

drfgen

This launches an interactive wizard that will guide you through:

  1. Naming your Django project
  2. Choosing the Django version to use
  3. Selecting whether to include Django REST Framework (and its version)
  4. Picking a Swagger tool for API docs (optional)
  5. Choosing authentication method (JWT, OAuth2, or none)
  6. Selecting project settings structure (simple or advanced with .env support)
  7. Picking your database backend
  8. Enabling or disabling API versioning

Once you finish answering the prompts, DRFGen will:

  • Create a project directory with the chosen name
  • Create a Python virtual environment inside the project folder
  • Install Django and other required packages into the venv
  • Initialize a Django project with the specified Django version
  • Apply advanced settings if requested
  • Freeze dependencies into requirements.txt
  • Install and configure Django REST Framework and authentication packages as needed
  • Install and configure Swagger tools if selected
  • Install common Django packages depending on your database and settings
  • Save your configuration to drfgen_config.json
  • Generate a custom management command called drfgen_startapp for creating apps

You will see colorful terminal output indicating the progress of each step.


The drfgen_startapp Custom Command

Creating Django apps with specific customizations can be time-consuming, especially if you want to keep your project consistent with your choices such as DRF integration, authentication setup, and settings structure.

To solve this, DRFGen generates a custom Django management command named:

python manage.py drfgen_startapp <app_name>

How does it differ from the default startapp?

Aspect Default startapp DRFGen drfgen_startapp
Base Template Minimal default Django app template Custom app template aligned with your project setup, including DRF integrations, auth scaffolding, etc.
INSTALLED_APPS You must manually add app to settings Automatically adds the new app to your INSTALLED_APPS in settings file
Extra Boilerplate None Includes ready-to-use files like serializers, views, urls configured according to your auth, API versioning, etc.
Saves Time & Reduces Errors Requires manual customization post-creation Automates and standardizes app creation based on your DRFGen project choices
CLI Command python manage.py startapp <app_name> python manage.py drfgen_startapp <app_name>

Benefits

  • Consistency: All your apps follow the same conventions and patterns.
  • Speed: No more repetitive boilerplate code creation — saves hours per app.
  • Easy Integration: Apps come pre-configured to work with authentication and API versioning as per your initial choices.
  • Less Error-Prone: Automatically modifies your INSTALLED_APPS, preventing forgotten steps.

Example Workflow

  1. Run drfgen CLI and select options (Django 4.2, DRF 3.14, JWT auth, PostgreSQL, advanced settings, etc.)
  2. After project setup finishes, navigate into your new project folder:
    cd myproject
    
  3. Use the custom app creation command:
    python manage.py drfgen_startapp users
    
  4. The users app will be created with your custom structure, and automatically added to INSTALLED_APPS.

Why Use DRFGen?

Manually setting up Django REST Framework projects for production-grade apps involves many tedious steps — from environment setup, dependency management, to configuring authentication and documentation. DRFGen automates this entire process with a user-friendly CLI.

The custom app command ensures that every new app fits perfectly into your project without wasting time on repetitive boilerplate and manual config edits.


Development

To contribute or develop locally:

git clone https://github.com/tahericode/DRFgen.git
cd drfgen
pip install -e .
drfgen

License

MIT License


Contact

For questions or feedback, please open an issue on GitHub or contact the maintainer.

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

drfgen-0.1.2.tar.gz (15.9 kB view details)

Uploaded Source

Built Distribution

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

drfgen-0.1.2-py3-none-any.whl (18.3 kB view details)

Uploaded Python 3

File details

Details for the file drfgen-0.1.2.tar.gz.

File metadata

  • Download URL: drfgen-0.1.2.tar.gz
  • Upload date:
  • Size: 15.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.3

File hashes

Hashes for drfgen-0.1.2.tar.gz
Algorithm Hash digest
SHA256 ec00608a53fc377f765c65fd6838e801df95686d8c61498ed7ed5093fe859db5
MD5 0f0a9786e4e90f7f4e67320b423931d9
BLAKE2b-256 27873937033f7b152e26e605e3b5e7cac66cb6a4a49ea6b5b20a46c83559e881

See more details on using hashes here.

File details

Details for the file drfgen-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: drfgen-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 18.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.3

File hashes

Hashes for drfgen-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1068424b0c88c05e85bf1c738b34b068093cb4921ced34f462f2e051c300a01c
MD5 970f2afe66939507f428304686646186
BLAKE2b-256 a6eb1e23a69e5a2c87b8f7a8dfd7ea15d79b68de4f774280cc0ef2f95cd40058

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