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
Post your comments / questions
Recent Article
- How to fix HAXM is not installed |in Android Studio
- How to fix CMOS Checksum Error in Computer or Laptop | SOLVED
- Reactivating windows after a Hardware change on PC or Laptop
- FIXED: Windows reported that the hardware of your device has changed. Error code :0xc004F211
- This action cannot be completed because the file is open in SQL Server(SQLEXPRESS) - FIXED
- Unicode error 'unicodeescape' codec can't decode bytes in position 2-3: truncated UXXXXXXXX escape
- Could not find the 'angular-devkit/build-angular:dev-server' builder's node package | Angular Error
- Error: error:0308010C:digital envelope routines::unsupported
Related Article