我的模特是:
Result search(T something,Set<T> someSet);
为了得到我想要的东西,我会在下面查询一个原始的SQL查询:
class Profiles(models.Model):
first_name = models.CharField()
last_name = models.CharField()
email = models.CharField()
class Meta:
db_table = 'users'
class Products(models.Model):
title = models.CharField()
content = models.CharField()
price = models.BigIntegerField()
user = models.ForeignKey(Profiles, related_name="product_owner") # user_id
class Meta:
db_table = 'products'
class UserFollows(models.Model):
profile = models.ForeignKey(Profiles, related_name='profile_following') # profile_id
following = models.ForeignKey(Profiles, related_name='profile_is_following') # following_id
class Meta:
db_table = 'user_follows'
但是我需要用Django ORM来做。 我可以加入&#39;用户&#39;和&#39;产品&#39;使用select_related的表但我不知道如何加入&#39; user_follows&#39;。我需要在&#39; user_follows&#39;的字段上应用过滤器。表。 请帮忙!