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

Erorr: name 'model_to_dict' is not defined

NameError: name 'model_to_dict' is not defined

Solution: Import the 'model_to_dict' module

# Add the following line to the top of your code
from django.forms.models import model_to_dict

 

For more information:
django model_to_dict