Advertisement
Guest User

Untitled

a guest
Sep 1st, 2015
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. url(r'^categories/(S+)/$',views.ItemListView.as_view(),name = 'Item-list'),
  2.  
  3. class ItemListView(generics.ListAPIView):
  4. serializer_class = ItemSerializer
  5. renderer_classes = (JSONRenderer,BrowsableAPIRenderer)
  6.  
  7. def get_queryset(self):
  8. category = get_object_or_404(Category, pk =self.args[0])
  9. return Items.objects.filter(category = category)
  10.  
  11. User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:40.0) Gecko/20100101 Firefox/40.0
  12. Origin: http://localhost:8000
  13. Host: 127.0.0.1:8000
  14. Connection: keep-alive
  15. Access-Control-Request-Method: GET
  16. Access-Control-Request-Headers: content-type
  17. Accept-Language: en-US,en;q=0.5
  18. Accept-Encoding: gzip, deflate
  19. Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
  20.  
  21. $('#category-box-list').on('click',function(){
  22. console.log('selected');
  23. var cat = $('#category-box-list').val();
  24. $.ajax({
  25. type :'GET',
  26. url :'http://127.0.0.1:8000/billing/categories/' + cat,
  27. contentType: 'application/json',
  28. crossDomain:true,
  29. success : function(json){
  30. console.log(json);
  31. }
  32. });
  33. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement