from django.db import models
class SeekerRegister(models.Model):
seeker_name = models.CharField(max_length=256,null=True,blank=True)
seeker_email = models.CharField(max_length=256,null=True,blank=True)
seeker_contact_no = models.CharField(max_length=256,null=True,blank=True)
seeker_password = models.CharField(max_length=256,null=True,blank=True)
seeker_ssp = models.CharField(max_length=32,null=True,blank=True)
verified = models.BooleanField(default=False)
type = models.IntegerField(default=1)
is_seeker_profile_updated = models.BooleanField(default=False)
def __str__(self):
return self.seeker_name
class KeySkills(models.Model):
skills = models.TextField()
versions = models.DecimalField(decimal_places=3,null=True,blank=True,max_digits=10,default=None)
experience = models.DecimalField(decimal_places=3,null=True,blank=True,max_digits=10,default=None)
user = models.ForeignKey(access_models.SeekerRegister,on_delete=models.CASCADE,related_name='key_skills',null=True,blank=True)
def __str__(self):
return "KeySkills"
查询我正在使用:
SeekerRegister.objects.exclude(key_skills__skills__in=['python']).all()
错误:
SQLDecodeError at /api/seeker/advance/search/
FAILED SQL: SELECT "access_seekerregister"."id", "access_seekerregister"."seeker_name", "access_seekerregister"."seeker_email", "access_seekerregister"."seeker_contact_no", "access_seekerregister"."seeker_password", "access_seekerregister"."seeker_ssp", "access_seekerregister"."verified", "access_seekerregister"."type", "access_seekerregister"."is_seeker_profile_updated" FROM "access_seekerregister" INNER JOIN "seeker_keyskills" ON ("access_seekerregister"."id" = "seeker_keyskills"."user_id") INNER JOIN "seeker_candidatecompanydetails" ON ("access_seekerregister"."id" = "seeker_candidatecompanydetails"."user_id") INNER JOIN "seeker_contactinfo" ON ("access_seekerregister"."id" = "seeker_contactinfo"."user_id") INNER JOIN "seeker_candidatedetails" ON ("access_seekerregister"."id" = "seeker_candidatedetails"."user_id") INNER JOIN "seeker_candidateeducationdetails" ON ("access_seekerregister"."id" = "seeker_candidateeducationdetails"."user_id") WHERE (NOT ("access_seekerregister"."id" IN (SELECT U1."user_id" FROM "seeker_keyskills" U1 WHERE (U1."skills" IN (%(0)s) AND U1."user_id" IS NOT NULL))) AND "seeker_keyskills"."skills" IN (%(1)s, %(2)s) AND "seeker_keyskills"."skills" IN (%(3)s) AND "seeker_candidatecompanydetails"."designation" iLIKE %(4)s AND "seeker_contactinfo"."current_location" iLIKE %(5)s AND "seeker_contactinfo"."job_type" = %(6)s AND "seeker_candidatedetails"."notice_period" <= %(7)s AND "seeker_contactinfo"."gender" = %(8)s AND "seeker_contactinfo"."diferently_abled" = %(9)s AND "seeker_candidateeducationdetails"."degree" iLIKE %(10)s)
Pymongo error: OrderedDict([('ok', 0.0), ('errmsg', "Unrecognized expression '$nin'"), ('code', 168), ('codeName', 'InvalidPipelineOperator')])
Version: 1.2.30
Request Method: GET
Request URL: http://127.0.0.1:8000/api/seeker/advance/search/?skills_any=python,react¬ice_period=30&gender=1&job_type=1&position=ceo°ree=bachelor%20degree¤t_location=bengaluru&disables=true&skills_must=react
Django Version: 2.1.3
Python Executable: /usr/local/bin/python
Python Version: 3.6.7
Python Path: ['/usr/src/jobster_api/src', '/usr/local/lib/python36.zip', '/usr/local/lib/python3.6', '/usr/local/lib/python3.6/lib-dynload', '/usr/local/lib/python3.6/site-packages']
Server time: Mon, 14 Jan 2019 21:55:07 +0530
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'corsheaders',
'rest_framework',
'django_elasticsearch_dsl',
'seeker',
在这里,我尝试使用上述查询过滤相关字段,并获得上述错误。
我要检查列表中是否不存在名称。 然后尝试排除
请看看
答案 0 :(得分:0)
您打错字了 改变这个
SeekerRegister.objects.filter(seeker_name__nin=['soubhagya']).values()
到
SeekerRegister.objects.exclude(id__in=[1,2,3]).values('key_skills__experience')