开发者

InterfaceError: Error binding parameter 0 - probably unsupported type

开发者 https://www.devze.com 2023-02-12 14:28 出处:网络
i have the following: class Tag( models.Model ): name = models.CharField( max_length=64 ) class Tag2Node( models.Model ):

i have the following:

class Tag( models.Model ):
    name = models.CharField( max_length=64 )

class Tag2Node( models.Model ):
    ip = models.IPAddressField( db_index=True )
    tag  = models.ForeignKey( Tag )
    last_update = m开发者_运维问答odels.DateTimeField( auto_now=True )

class Node( models.Model ):
    id = models.CharField( primary_key=True, max_length=64 )
    ip = models.IPAddressField( db_index=True )
    method = models.CharField( max_length=64 )

(plus some other stuff)

basically i can't do a ForeignKey on the Node.ip as it's rows not unique (i may have may methods for the same ip).

so in order to query i do a

found_ips = Tag2Node.objects.filter( tag__name=include ).values('ip').distinct()
q = Q( ip__exact=found_ips[0] )
nodes = Node.objects.get( q )

but i get the error:

InterfaceError: Error binding parameter 0 - probably unsupported type.

any ideas? cheers,


The error comes from you passing a dictionary to get

I'm not sure why this error doesn't throw something else instead...

found_ips = Tag2Node.objects.filter( tag__name=include ).values('ip').distinct()
# values returns a dictionary
q = Q( ip__exact=found_ips[0]['ip'] ) 
nodes = Node.objects.get( q )
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号