Django Tools CLI is a command-line interface (CLI) tool written in Rust 🦀 to quickly create APIs in Django. It provides commands to generate different components of a Django project, such as ViewSet, ApiView, and new projects.
- Windows or Linux
- For Linux,
sh
(shell) environment is required.
- For Linux,
- Python 3 or later
- Rust 🦀 (Optional: Required only if you want to compile or modify the project)
-
Download binaries: You can download pre-built binaries for your operating system from the releases section of the Django Tools CLI GitHub repository.
-
Build from source (Alternative): If you prefer, you can build the project from the source code. Clone the repository and navigate to the project directory. Then, follow these steps:
-
Windows:
- Take the generated
.exe
file, for example,django-tools.exe
, and place it in a directory of your choice. For instance, you can place it inC:\Program Files
. - Copy the entire directory path where the
.exe
file is located. - Add the copied directory path to the system's environment variables. To do this:
- Search for "Environment Variables" in the Windows search bar and open the system's environment variables settings.
- In the System Properties window, click on the "Environment Variables" button.
- Under "System variables", find the "Path" variable, select it, and click on "Edit".
- Click on "New" and paste the directory path where the
.exe
file is located. - Click "OK" on all windows to save the changes.
- Take the generated
-
Linux:
- Take the generated binary file (executable), typically located at
target/release/django-tools
after building the project. - Move or copy the binary file to
/usr/local/bin
directory using the following command:sudo cp target/release/django-tools /usr/local/bin/
- You might need to use
sudo
to have the necessary permissions to copy the file.
- Take the generated binary file (executable), typically located at
-
You can utilize Django Tools CLI with the following commands:
To initiate a new Django project, use the following command:
django-tools Project -n backend
This command will create a new Django project named "backend".
To generate a ViewSet app within your Django project, use the following command:
django-tools ViewSet -n ducks
This command will generate a ViewSets app named "ducks" within your Django project.
To generate an ApiView app within your Django project, use the following command:
django-tools ApiView -n dogs
This command will create an ApiView app named "dogs" within your Django project.