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

Erorr: name 'Q' is not defined

NameError: name 'Q' is not defined

Solution: Import the 'Q' module

# Add the following line to the top of your code
from django.db.models import Q

 

For more information:
django Q