Python 通过外键的Django过滤器
我需要搜索userid>0的用户朋友Python 通过外键的Django过滤器,python,django,django-models,Python,Django,Django Models,我需要搜索userid>0的用户朋友 class UserTomonotomo(models.Model): userid= models.BigIntegerField(null=False, unique=True, db_index=True) email= models.CharField(max_length=100L, null=True) ###################### ######## class UserFriends(mode
class UserTomonotomo(models.Model):
userid= models.BigIntegerField(null=False, unique=True, db_index=True)
email= models.CharField(max_length=100L, null=True)
######################
########
class UserFriends(models.Model):
userid= models.ForeignKey('UserTomonotomo', to_field='userid', null=False)
friendid = models.BigIntegerField(null=False)
不工作,因为张贴在!!有什么问题吗。我使用的是django版本1.5.2
谢谢使用:
有关其他操作员,请参阅。使用:
有关其他操作员的信息,请参阅。谢谢。这很有效。我实际上需要检查userid是否在python列表中。我该怎么做呢?@PratikPoddar,那么,使用_contains.@PratikPoddar,如果我的回答有帮助,请接受回答。谢谢。这很有效。我实际上需要检查userid是否在python列表中。我该怎么做呢?@PratikPoddar,那么,使用uu contains.@PratikPoddar,如果我的回答有帮助,请接受回答。
UserFriends.objects.filter( userid__userid > 0 )
UserFriends.objects.filter(userid__userid__gt=0)