Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/337.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用tastypie进行ToOneField滤波_Python_Django_Tastypie - Fatal编程技术网

Python 使用tastypie进行ToOneField滤波

Python 使用tastypie进行ToOneField滤波,python,django,tastypie,Python,Django,Tastypie,我尝试使用OneToField字段过滤ressource 我希望获得此url提供的最喜爱的相关任务安全密钥: /收藏夹/api/all/?任务\安全\密钥=sdsd900kljhiu987bbhU 和tastypie返回: {"error": "The 'secure_key' field does not allow filtering."} 这是我的档案: 收藏夹/api.py class FavoriteRessource(ModelResource): task = field

我尝试使用OneToField字段过滤ressource

我希望获得此url提供的最喜爱的相关任务安全密钥:
/收藏夹/api/all/?任务\安全\密钥=sdsd900kljhiu987bbhU

和tastypie返回:

{"error": "The 'secure_key' field does not allow filtering."}
这是我的档案:

收藏夹/api.py

class FavoriteRessource(ModelResource):
    task = fields.ToOneField('task.api.TaskResource', attribute='task', full=True)
    user = fields.ToOneField('foruser.api.UserRessource', attribute='user', full=True)

    class Meta:
        queryset = Favorite.objects.all()
        resource_name = 'all'
        excludes = ['id']
        allowed_methods = ['get', 'post']
        include_resource_uri = False
        authentication = BaseAuthentication()
        authorization = Authorization()
        filtering = {
            'task': ALL_WITH_RELATIONS,
        }
任务/api.py

class TaskResource(ModelResource):
    city = fields.ToOneField(AppCityRessource, attribute='city', null=True, full=True)
    category = fields.ToOneField(TaskCategoryResource, attribute='category', null=True, full=True)
    user = fields.ToOneField(UserRessource, attribute='user', null=True, full=True)
    skill = fields.ToManyField(SkillRessource, attribute='skill', full=True)

    class Meta:
        #queryset = Task.objects.filter(active=True, admin_active=True, skill_active=True)
        queryset = Task.objects.all()
        resource_name = 'all'
        excludes = ['active', 'admin_active', 'skill_active', 'participant_history']
        allowed_methods = ['get', 'post', 'put', 'delete']
        always_return_data = True
        include_resource_uri = False
        authentication = BaseAuthentication()
        authorization = Authorization()        
        filtering = { 
            'secure_key': ALL,
        }

我的错误在哪里?

您是否尝试将
secure\u key
添加为TaskResource的返回字段之一(城市、类别、用户等旁边)?如果成功,并且您不希望将
secure\u key
作为返回字段,则通过
dehydrate
No将其删除,因为secure\u key是任务模型的一个字段。