情况是这样的:我有3个这样定义的模型: class State(models.Model): city = models.ForeignKey(City, related_name='homes', on_delete=models.RESTRICT) 人们需要对房屋的反应是这样的serializers.ModelSerializer):
city = Slu
我不知道把数据添加到查询集会如此困难。就像,如果它不是直接来自数据库,那么它也可能不存在。即使当我注释时,新的字段也是二等公民,并不总是可用的。
# Regular Django fields corresponding to the attributes in thedef __str__(self): # __unicode__ on Python 2
re
为了提高大型查询的性能,我使用includes method来立即加载关系。我想知道是否有一种简单的方法来计算代码块执行的实际查询数,以便我可以检查我的includes是否真的像预期的那样减少了DB访问的数量。Mongoid.count_queries doend
puts count # Number of DB access 我想使用此功能来添加Rspec测