我想过滤我的对象。但我收到此错误inventory?assigned=S5&manufacturer=S5&model=S5 400 (BAD REQUEST)
和Invalid resource lookup data provided (mismatched type)
$scope.filter_all = function(value) {
$scope.filtered_inventories = new Inventory().query({model: value, manufacturer: value, assigned: value}).$object;
};
这是我的模板,我使用选择字段按模式,制造商和用户过滤库存
<!--filtering-->
<!--filter inventory Model-->
<select ng-model="inventory.model" ng-change="filter_all(inventory.model)">
<option value="">Model</option>
<option ng-repeat="inventory in inventories | unique:'model'" value="{{inventory.model}}">{{inventory.model}}</div>
</select>
<!--filter inventory Manufacturer-->
<select ng-model="inventory.manufacturer" ng-change="filter_all(inventory.manufacturer)">
<option value="">Manufacturer</option>
<option ng-repeat="inventory in inventories | unique:'manufacturer'" value="{{inventory.manufacturer}}">{{inventory.manufacturer}}</div>
</select>
<!--filter inventory Holder-->
<select ng-model="inventory.assigned" ng-change="filter_all(inventory.assigned)">
<option value="">Holder</option>
<option ng-repeat="inventory in inventories" value="{{inventory.assigned.id}}">{{inventory.assigned.first_name + ' ' + inventory.assigned.last_name}}</div>
</select>
编辑:我的api.py文件
class InventoryResource(ModelResource):
assigned = fields.ForeignKey('inventory.api.AssignedResource', 'assigned', full=True, null=True)
location = fields.ForeignKey('inventory.api.LocationResource', 'location', full=True, null=True)
tags = fields.ToManyField(TagResource, 'tags', full=True, null=True)
class Meta:
queryset = Inventory.objects.all()
resource_name = 'inventory'
list_allowed_methods = ['get', 'put', 'post', 'delete', 'copy']
detail_allowed_methods = ['get', 'put', 'post', 'delete', 'copy']
authorization = DjangoAuthorization()
authorization = Authorization()
serializer = Serializer()
filtering = {'id': ALL, 'barcode': ALL, 'model': ALL, 'manufacturer': ALL, 'location': ALL, 'tags': ALL, 'assigned': ALL, 'inventory': ALL}