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
- 👉 2# - Enable the model in the
- 👉 3# -
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
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
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: