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!
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/ac684cc5-6d93-497e-b93e-f7b486b0efa8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.