c# .net Adsense ADO.NET Linq Viruses/security asp.net MVC JQuery Angular-js Node-js SEO Java C++ SQL API Networking vb.net .Net Css JavaScript Generics c#.Net entity framework HTML Website host Website Construction Guide HTTP tutorial W3C tutorial Web Services JSON Psychology Ionic framework Angular ReactJS Python Computer Android
Python

"redirect" is not defined pylance("reportUndefinedVariable)

| | python
I got this following error in my django python project.
"redirect" is not defined pylance("reportUndefinedVariable)
CODE:
from django.shortcuts import render

from . models import *
from django.contrib import messages


def collectionsview(request,name):
if(Category.objects.filter(name=name,status=0)):
products=Product.objects.filter(category__name=name)
return render(request,"shop/products/index.html",{"products":products,"category_name":name})
else:
messages.warning(request,"No Such Catagory Found")
return redirect('collections')
To resolve this problem need to import redirect on top,
from django.shortcuts import render, redirect