Skip to content

Command-Line Interface to create APIs quickly in Django

License

Notifications You must be signed in to change notification settings

xansaul/django-tools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Django Tools CLI

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.

Requirements

  • Windows or Linux
    • For Linux, sh (shell) environment is required.
  • Python 3 or later
  • Rust 🦀 (Optional: Required only if you want to compile or modify the project)

Installation

  1. Download binaries: You can download pre-built binaries for your operating system from the releases section of the Django Tools CLI GitHub repository.

  2. 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 in C:\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.
    • 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.

Usage

You can utilize Django Tools CLI with the following commands:

Creating a new project:

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".

Creating a ViewSet app:

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.

Creating an ApiView app:

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.

Captura de pantalla 2024-04-27 184334