Django 如何使用数据库对象创建输入字符串
在这里,当我以Django 如何使用数据库对象创建输入字符串,django,Django,在这里,当我以newFeature的形式输入feature\u name时,它会给我找到的文件夹,但当我输入newFeature123时,它会给我找不到的文件夹 在FeatureCache表中,这两个是newFeature123和newFeature。这些文件夹名称存在,但与newFeature匹配,但与newFeature123不匹配 views.py: 在django queryset中查找 基本上,包含和icontains可能就是您要寻找的: FeatureCache.objects.fi
newFeature
的形式输入feature\u name时,它会给我找到的文件夹,但当我输入newFeature123
时,它会给我找不到的文件夹
在FeatureCache表中,这两个是newFeature123
和newFeature
。这些文件夹名称存在,但与newFeature匹配,但与newFeature123不匹配
views.py:
在django queryset中查找
基本上,包含
和icontains
可能就是您要寻找的:
FeatureCache.objects.filter(project\uu icontains=feature\u name,project\uu exact=project\u id)
它将执行不区分大小写的查找。大概是这样的:
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"})
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"})