0
我使用Tastypie
由barcode
tastypie過濾數據
我該如何使用它,並在前端濾波器它在後端過濾數據
class Meta:
queryset = Inventory.objects.all()
resource_name = 'inventory'
filtering = {'barcode': ALL}
在api/v1/inventory/?format=json&barcode=1232141542625235624
我得到過濾後的數據使用AngularJS?
app.controller('InventoryListCtrl', function($scope, Inventory, Restangular, inventoryItems) {
$scope.inventories = inventoryItems;
};
我的國家
app.config(function config($stateProvider, $urlRouterProvider) {
$stateProvider.state('inventory',{
url:'/inventory',
views: {
"main": {
controller: 'InventoryCtrl',
templateUrl: 'inventory/main.tpl.html'
}
},
data:{ pageTitle: 'Inventory' }
}
).state('inventory.listview',{
url:'/listview/',
views: {
"listview": {
controller: 'InventoryListCtrl',
templateUrl: 'inventory/inventory.listview.tpl.html'
}
},
data:{ pageTitle: 'Listview' },
resolve: {
inventoryItems: function(Inventory, $stateParams){
return new Inventory().query();
}
}
})
有我的模板
<ul style="list-style:none;">
<li>{{inventory.manufacturer}} {{inventory.model}}</li></a>
<li><b>Barcode:</b> {{inventory.barcode}}</li>
<li><b>Holder:</b> {{inventory.user.first_name}} {{inventory.user.last_name}}</li>
<li><b>Tags:</b> {{inventory.tags.tags}}</li>
</ul>