我有四个与餐馆有关的模型,我很难返回正确的结果。
模型为AdminEnteredRestaurant
,Restaurant
,Photo
,Menu
,定义如下:
class AdminEnteredRestaurant(models.Model):
restaurant = models.OneToOneField(Restaurant)
...
class Restaurant(models.Model):
name = models.CharField(max_length= 100)
...
class Photo(models.Model):
restaurant = models.ForeignKey(Restaurant)
...
class Menu(models.Model):
restaurant = models.OneToOneField(Restaurant)
...
我想要的查询是过滤所有AdminEnteredRestaurant
并仅返回具有1个或更少AdminEnteredRestaurant
个和0个菜单的Photo
个compile ('com.ourcompany:sdk:2.1.16@aar') {
transitive = true
}
。我该怎么做呢?