Django Rest API – Browsable API – Part4

This is one the exciting features of DRF let’s see what it is.

To get start we need to install few packages

pip install djangorestframework
pip install markdown       # Markdown support for the browsable API.
pip install django-filter  # Filtering support

Once done in the file add this


and the main file

from django.contrib import admin
from django.urls import path, include, re_path as url

urlpatterns = [
    url(r'^', include('todo.urls')),
    url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework'))

Notice how i removed “^todo/’ from our This is required i.e “url(r'^’, include(‘todo.urls’)),” without this for me browsable api were not showing up.

Once this is done, restart server and open in your browser directly. It will ask for login. If you don’t remember login create one using

Then you should see this

This is great! We have full api documentation created for us and we can easily share with frontend dev’s using this.

Also click on individual api to see further drill down.

Here we see a form to add data and play around with the api’s we have.

and also if you deploy the django app on server and Css does not render on admin panel and browsable api page do the following step

install dj_static with
pip install dj-static

then in file add

STATIC_ROOT = 'staticfiles'
STATIC_URL = '/static/'

then finally in your file write this

from dj_static import Cling

application = Cling(your_application_name())