How to Solve NameError: name 'constants' is not defined -- django
Solution: Import the 'constants' module
To Solve the error, add the following line to the top of your code.
from django.contrib.messages import constants
For more information:
Python django constants