如何在没有任何理由的情况下阻止TastyPie执行UPDATE查询?

Pro*_*eus 9 python django tastypie

我在申请中看到了一些常见的事情.当我很少或没有流量时,我的服务器无缘无故地放慢速度.经过大量的试验和错误后,我发现当我删除了ToOneField我的TastyPie资源时,我的问题就消失了!

我发现的是由于一些未知的原因,TastyPie正在这些ToOneFields上进行数据库更新,这是没有充分理由的!什么......时刻!

在此输入图像描述

我在这里发现了一个可能的错误,声称修复了更新问题.我已经安装了最新版本,pip但仍然看到了这个问题.

有人可以帮忙吗?

class IncentiveResource(ModelResource):
    product_introducer = fields.ToOneField(ProductResource, 'referrer_product', full=True)
    product_friend = fields.ToOneField(ProductResource, 'referee_product', full=True)

    class Meta:
        queryset = Incentive.objects.all().order_by('-date_created')
        resource_name = 'incentive'
        allowed_methods = ['get']
        authentication = MultiAuthentication(ClientAuthentication(), ApiKeyAuthentication())
        authorization = Authorization()
        filtering = {
            "active": ALL,
        }
        always_return_data = True
        cache = SimpleCache(cache_name='resources', timeout=10)
Run Code Online (Sandbox Code Playgroud)

这里交通很少,但变得无法使用. 在此输入图像描述 在此输入图像描述

Far*_*han 2

我不知道这是否会对您有帮助,但我发现我select_related在查询集和full=True资源字段中使用时所开发的应用程序的性能略有提高。

尝试queryset = Incentive.objects.select_related('product_introducer', 'product_friend').all().order_by('-date_created')