0

Here when I give input to feature_name as newFeature, it gives me folder found but when I give newFeature123, it gives me folder not found

In FeatureCache table these two are newFeature123 and newFeature. These folder name are present but its match with newFeature but not with newFeature123.

views.py:

def passReviewerProjFeature(request):
    if request.method == 'POST':
        feature_name = request.POST['tcrsearch_id']
        project_id = request.POST['tcrproject_id']
        featureObjectarray=FeatureCache.objects.filter(project=project_id)
        for object in featureObjectarray:
               print object.name
               if feature_name not in str(object.name):
                   print feature_name
                   print "not Present"
                   return render(request,'index.html',{'errmsg':"Folder Not Found"})
               else:
                   return render(request,'index.html',{'errmsg':"Folder Found"})

1 Answer 1

1

Look for field lookups in django queryset.

Basically contains and icontains may be what you are looking for:

FeatureCache.objects.filter(project__icontains=feature_name, project__exact=project_id)

which will do case insensitive lookup. Something like this:

featureObjectarray=FeatureCache.objects.filter(project__icontains=feature_name, project__exact=project_id)
if featureObjectarray.exists():
  return render(request,'index.html',{'errmsg':"Folder Found"})
else:
  print feature_name
  print "not Present"
  return render(request,'index.html',{'errmsg':"Folder Not Found"})
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.