/drf-cli

Command Line Interface for Django Rest Framework

Primary LanguagePythonMIT LicenseMIT

DRF CLI: Project Management for Django + Django Rest Framework

DRF CLI helps you create and manage Django + DRF projects, ensuring you have the best development tools in a fast way.

Install

Assuming you have already installed Python 3.8+... Install the DRF CLI tool.

$ pip install drf-cli

Create project

Create a new Django + DRF project.

$ drf new project

Create backend APIs through models

Executing the following command it will generate a new Model (and the full combination of Model Serializer, Model ViewSet, Route, Migration, etc...)

$ drf new model

The generator guides you through creating your resource. Enter the values. To accept the default, just press Enter.

[?] Enter the model name: pizza
[?] Custom plural form: pizzas
Let's add some model properties now.

Define a property for model

Enter an empty property name when done.
[?] Property name: size

Choose the property type:

[?] Property type:
* [1] string
  [2] integer
  [3] boolean
  [4] decimal
  [5] float
  [6] date
  [7] datetime

Make the property required or not:

[?] Required? (y/N) y

Repeated these steps until define all model properties you need.

Press Enter when prompted for a property name to finish up and create the resource.

Run the project:

Run as you would any Django application.

$ python manage.py runserver

Explore your REST API

Load http://0.0.0.0:8000/api to see the built-in API Explorer.

Development tools included

This tool follows the best development practices included in 12-factor app and in this blog post.