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

Solution: Import the 'api_view' module

# Add the following line to the top of your code
from rest_framework.decorators import api_view

 

For more information:
rest_framework api_view