class Promotion(models.Model): shop = models.ForeignKey(User, limit_choices_to=is_shop) class Brand(models.Model): id = models.PositiveIntegerField(primary_key=True) watches = models.ManyToManyField(User, blank=True, limit_choices_to=is_client, related_name="brand_watches") shops = models.ManyToManyField(User, blank=True, limit_choices_to=is_shop, related_name="brands_for_shop")
查询方法一般有:
#查询出含有brand——id 的所有用户 queryset_user = User.objects.filter(brands_for_shop__id=obj.id).values_list("id") demo=Promotion.objects.filter(shop__id=i).values_list("rebate_to_client")
时间: 2024-11-03 21:30:20