How to Solve NameError: name 'get_object_or_404' is not defined -- django

Erorr: name 'get_object_or_404' is not defined

NameError: name 'get_object_or_404' is not defined

Solution: Import the 'get_object_or_404' module

# Add the following line to the top of your code
from django.shortcuts import get_object_or_404

 

For more information:
django get_object_or_404