Installing Django REST framework

Django REST framework allows you to easily build REST APIs for your project. You can find all information about REST framework at https://www.django-rest-framework.org/.

Open the shell and install the framework with the following command:

pip install djangorestframework==3.8.2

Edit the settings.py file of the educa project and add rest_framework to the INSTALLED_APPS setting to activate the application, as follows:

INSTALLED_APPS = [    # ...    'rest_framework',]

Then, add the following code to the settings.py file:

REST_FRAMEWORK = {    'DEFAULT_PERMISSION_CLASSES':  'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly'    ]}

You can provide a specific configuration for your API using the REST_FRAMEWORK

Get Django 2 by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.