Browsing the secured API with the required authentication
We want the browsable API to display the log in and log out views. In order to make this possible, we have to add a line in the urls.py
file in the restful01/restful01
folder, specifically, in the restful01/restful01/urls.py
file. The file defines the root URL configurations and we want to include the URL patterns provided by the Django REST framework that provide the log in and log out views.
The following lines show the new code for the restful01/restful01/urls.py
file. The new line is highlighted. The code file for the sample is included in the hillar_django_restful_08_01
folder, in the restful01/restful01/urls.py
file:
from django.conf.urls import url, include
urlpatterns = [
url(r'^', include('drones.urls')),
url(r'^api-auth/', include('rest_framework.urls'))
]
Open a web browser and go to http://localhost:8000/
. Replace localhost by the IP of the computer that is running Django's development server in case you use another...