DRF CLI helps you create and manage Django + DRF projects, ensuring you have the best development tools in a fast way.
Assuming you have already installed Python 3.8+... Install the DRF CLI tool.
$ pip install drf-cli
Create a new Django + DRF project.
$ drf new project
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 as you would any Django application.
$ python manage.py runserver
Load http://0.0.0.0:8000/api to see the built-in API Explorer.
This tool follows the best development practices included in 12-factor app and in this blog post.
- Dependencies Management:
- Project Configurations
- Code Formating
- Style Enforcement
- Static Typing
- Testing and Coverage
- Git hooks
- Conteiners Management
- Authentication