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

Solution: Import the 'GenericForeignKey' module

# Add the following line to the top of your code
from django.contrib.contenttypes.fields import GenericForeignKey

 

For more information:
django GenericForeignKey