Django : HINT: No operator matches the given name and argument types. You might need to add explicit type casts

Viewed 477

I'm wondering why this error display and I've been using Postgresql and I have been observed this error occurs when I use IntegerField on my models like this one b2_sacnumber_id = models.IntegerField(blank=True, null=True) or even using Integer field in local database. Is there any solution to get the value even I used IntergerFiled in my models? Im new in postgres , Can anyone explain to me about this it really helps me a lot.

Error

LINE 1: ...sac_forms" WHERE "b2_sac_forms"."b2_sacnumber_id" IN (31718,...
                                                             ^
HINT:  No operator matches the given name and argument types. You might need to add explicit type casts.

query views.py

sample = ['31718','47060']
Sac_forms = list(B2SacForms.objects.using('matchy_data').values_list('b2_id', flat=True).filter(b2_sacnumber_id__in=sample))

What I tried changing the value sample like this one sample = ['31718','47060'] or sample = ["31718","47060"] and even I tried sample = [31718,47060] but still the error occurs

models.py

class B2SacForms(models.Model):
  b2_id = models.IntegerField(blank=True, null=True)
  b2_sacnumber_id = models.IntegerField(blank=True, null=True)
  date = models.DateField(blank=True, null=True)
  generated_id = models.IntegerField(blank=True, null=True)

class Meta:
    managed = False
    db_table = 'b2_sac_forms'
0 Answers
Related