A CLI tool to bootstrap Django REST Framework projects quickly and easily.
Project description
DRFGen CLI
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-spectacularordrf-yasg) for API documentation - Default common Django packages installed and configured
- Generates a
requirements.txtfile automatically - Saves project configuration in
drfgen_config.jsonfor easy reference - Custom Django management command
drfgen_startappto create Django apps tailored to your project settings — automatically adds the app toINSTALLED_APPSand 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:
- Naming your Django project
- Choosing the Django version to use
- Selecting whether to include Django REST Framework (and its version)
- Picking a Swagger tool for API docs (optional)
- Choosing authentication method (JWT, OAuth2, or none)
- Selecting project settings structure (simple or advanced with
.envsupport) - Picking your database backend
- 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_startappfor 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
- Run
drfgenCLI and select options (Django 4.2, DRF 3.14, JWT auth, PostgreSQL, advanced settings, etc.) - After project setup finishes, navigate into your new project folder:
cd myproject
- Use the custom app creation command:
python manage.py drfgen_startapp users
- The
usersapp will be created with your custom structure, and automatically added toINSTALLED_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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file drfgen-0.1.0.tar.gz.
File metadata
- Download URL: drfgen-0.1.0.tar.gz
- Upload date:
- Size: 7.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0a8ae5112e7239dae85b16acbc20ec20c67e7cd23ce3e01ef70e9694110dd896
|
|
| MD5 |
7facb700674c5c1730896bd0bdce1c15
|
|
| BLAKE2b-256 |
80ec8efc33266b4997bc3f02ec5b1f8078f5818a9e0604e240f4f34f429d7077
|
File details
Details for the file drfgen-0.1.0-py3-none-any.whl.
File metadata
- Download URL: drfgen-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e76b54eaae0aeb4ea5342f5b995a9124033c784d856d02d0fdcff7cb519c818c
|
|
| MD5 |
66cd0eac2b7664448e2c1209b4a51f84
|
|
| BLAKE2b-256 |
7ccca93ff8f4f865f5ecccbe69b48d6df4c40c3586b893fc157f325a3a63c7f8
|