I'm having a trouble on getting this error when filtering data on my postgresql, it says that the error comes from this line .filter(bene_id='31452')
. I've been using two tables in Django. I think the problem is on my operator =
since the id is integer but the problem is how and what should I replace in that operator ?
I tried putting double qoute, single qoute and even without elements like this .filter(bene_id="31452")
,.filter(bene_id=31452)
,.filter(bene_id='31452')
. But it seems the error has not been solve.it would be great if anybody could figure out where I am doing something wrong. thank you so much in advance
Error
LINE 1: ...2_benes_status" WHERE "b2_benes_status"."bene_id" = 31452 L...
^
HINT: No operator matches the given name and argument types. You might need
to add explicit type casts.
views.py
Testing = B2BenesStatus.objects.using('matchy_data').filter(bene_id='31452')
Models.py
class B2BenesStatus(models.Model):
datetime = models.DateTimeField(blank=True, null=True)
value = models.BooleanField(blank=True, null=True)
remarks = models.TextField(blank=True, null=True)
bene_id = models.IntegerField(blank=True, null=True)
stat_cat_id = models.IntegerField(blank=True, null=True)
updated_by_id = models.IntegerField(blank=True, null=True)
class Meta:
managed = False
db_table = 'b2_benes_status'
Settings.py
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'payroll',
'USER':'root',
'PASSWORD':'',
'HOST':'localhost',
'PORT':'3306',
},
'matchy_data': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'matchy_data',
'USER':'postgres',
'PASSWORD':'samplee',
'HOST':'localhost',
'PORT':'5432',
},}