DJANGO - Create your first Rest API.
Create a Django project first.
Install the Django Rest Framework by using this command.
pip install djangorestframework
Go to the settings.py file and add "rest_framework" to the installed list.
Create a URL to access the API.
Static Data
Create a view for the API that returns data in JSON format.
Run the server and access the URL; now, you will get the data in a JSON format.
Dynamic Data
Now we can fetch data from the database. For that, you need to create a model class. Then proceed with all migrations.
Change the views function a little more.
Django REST framework API
Now we can see how to use the Django-Rest framework for building APIs.
Create models.py file
Create serializers.py file
Create urls.py file
Create views.py file
Comments
Post a Comment