Hi Everyone,
Class FilterSearch(View):
template_name = 'approved/approvedElementsSEView.html
def post(self, request, testPlanId):
elemType = request.POST.get('testElementType);
elemCategory = request.POST.get('category');
if(elemCategory=='routing'):
testElement = ApprovedTestElement.objects.filter(testElemType=elemType,routing='Y');
elif(elemCategory=='switching'):
testElement = ApprovedTestElement.objects.filter(testElemType=elemType,switching='Y');
return render(request,self.template_name,{'testElement':testElement,'testPlanId':testPlanId})
I am trying to send a different testElement based on which if condition has been satisfied. I am new to Django and I keep getting UnboundLocalError Exception : local variable 'testElement' referenced before assignment . I have tried defining testElement outside the if loop, but maybe that's not the right way! Any Help will be greatly appreciated!