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.2.0.tar.gz (16.3 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.2.0-py3-none-any.whl (19.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for drfgen-0.2.0.tar.gz
Algorithm Hash digest
SHA256 61b63297b3b783b241bedc1ee69d32b3cbd472e32bb01c2237724783c3e4f5ba
MD5 3f36a2f6217fdc47c9dd0af66a4c35c3
BLAKE2b-256 e445a2fe1535df71cb1268e2ca55ec9671593876a6bdda16ba38bd6d9cc4bcc0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: drfgen-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 19.2 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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6e8e9237de834758ae5ab906728cb5e2d4b3ea7c4fdb3a555db41bed6cb900c9
MD5 584792bb223283a19664534d138289ec
BLAKE2b-256 2c4a2523d6239dabcbe77c41f592821fb5b55c16126b71f3278a4f219883b596

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