Dynamic API - New feature available (PRO starters)
Hello Coders! This article presents Dynamic API
, the latest feature available for the Django Datta PRO starter and soon available for all related Django PRO starters. This pattern allows exposing an API interface over any model used in the project with a minimal coding interaction. Here are the steps:
- 👉 1# - Define your model in
apps/models.py
- 👉 2# - Enable the model in the
configuration
- 👉 3# -
Migrate
the project
Step 2 is introduced to empower the developer to filter exposed models with ease. Once the above steps are finished, the CRUD operations (Create, Read, Update, Delete) are available via localhost/api/<MODEL_NAME>/
URI.
The first starter updated with this feature is Django Datta Able PRO using a simple Books
model defined as below:
As mentioned before, the model exposure in the DRF interface should be enabled in the configuration.
At this point, we need to migrate the project using the classic commands:
$ python manage.py makemigrations
Migrations for 'dyn_api':
apps\dyn_api\migrations\0001_initial.py
- Create model Books
And the migrate
command:
python manage.py migrate
Operations to perform:
Apply all migrations: dyn_api
Running migrations:
Applying dyn_api.0001_initial... OK
To interact with the API we can use POSTMAN or the default DRF Interface.
To see the service in action for Books
model, please access the links:
- 👉 API Books - exposed by Datta Able PRO Demo
- 👉 Datta Able PRO Django - product page