python - 使用过滤器搜索公司出现错误,获取类型错误只能将str(Not nonetype)连接到views.py中的str在线compsearchobj
问题描述
我使用这个定义来定义搜索和过滤页面,使用一个连接和保存的数据库。我已经为此添加了 views.py 和 models.py 代码。
视图.py
def multiplesearchcomp(request):
if request.method=="POST":
citycode=request.POST.get("citycode")
statecode=request.POST.get("statecode")
countrycode=request.POST.get("countrycode")
revenue=request.POST.get("revenue")
noofemployees=request.POST.get("noofemployees")
domaincode=request.POST.get("domain_id")
compsearchobj=DisplayCompanyDomain.objects.raw('select * from enquire_automation_app_displaycompanydomain where citycode="'+citycode+'" and statecode="'+statecode+'" and countrycode="'+countrycode+'" and domain_id="'+domaincode+'" and revenue="'+revenue+'" and noofemployees="'+noofemployees+'"')
return render(request,'filtercompany.html',{"DisplayCompanyDomain":compsearchobj,"countries": Country_master.objects.all(), 'states': State_master.objects.all(), "cities": City_master.objects.all(), "domains": Domain_master.objects.all()})
else:
compobj=DisplayCompanyDomain.objects.raw('select * from enquire_automation_app_displaycompanydomain')
return render(request,'filtercompany.html',{"DisplayCompanyDomain":compobj, "countries": Country_master.objects.all(), 'states': State_master.objects.all(), "cities": City_master.objects.all(), "domains": Domain_master.objects.all()})
模型.py
class DisplayCompanyDomain(models.Model):
companyname = models.CharField(max_length=100)
address = models.CharField(max_length=200)
citycode = models.CharField(max_length=20)
statecode = models.CharField(max_length=20)
countrycode = models.CharField(max_length=20)
foundedin = models.CharField(max_length=20)
revenue = models.CharField(max_length=100)
noofemployees = models.CharField(max_length=20)
domesticprojects = models.IntegerField(default=0)
globalprojects = models.IntegerField(default=0)
website = models.CharField(max_length=50)
domain_id=models.CharField(max_length=20)
no_of_projects=models.IntegerField()
解决方案
推荐阅读
- excel - 如何删除power query excel中列中的最后一个字符?
- react-native - const source = { uri: audioUrl } 找不到我的本地文件
- apache-spark - 用于匹配字符串的 Pyspark 函数
- html - Flexbox div 不占用整个垂直空间
- go - 其他 goroutine 创建的指针的指针通道
- android - 在Android中,如何根据sigcontext获取stacktrace
- vb.net - 如何在 DataGridView 中禁用单击并仅通过双击选择记录
- python - AttributeError:“MySQLDatabase”对象没有属性“create_table”
- ios - Swiftui - 删除列表行
- c# - C#/Selenium - 使用 contains() 找不到 XPath 文本