How to Solve NameError: name 'DefaultRouter' is not defined -- rest_framework

Solution: Import the 'DefaultRouter' module

# Add the following line to the top of your code
from rest_framework.routers import DefaultRouter

 

For more information:
rest_framework DefaultRouter