defStaple(request): # Give all staple directly for choose Staple = ITEM_CATEGORY[ITEM_CATEGORY['ITEM_CATEGORY'] == 'Staple'] list = [] for index in Staple.index: list.append({'id': str(index), 'name': str(Staple.loc[index, 'ITEM_DESCRIPTION'])}) return JsonResponse({'data': list})
defPrice(request): # Give all price.dropduplicates directly for choose Price = pd.DataFrame( ITEM_CATEGORY[ITEM_CATEGORY['ITEM_CATEGORY'] == 'Staple']['PRICE'].drop_duplicates().sort_values()) list = [] for index in Price.index: list.append({'id': str(index), 'name': str(Price.loc[index, 'PRICE'])}) return JsonResponse({'data': list})
defStapleSelected(request, id): # When cilcking on a staple, get the price Price = ITEM_CATEGORY.loc[int(id), 'PRICE'] list = [] list.append({'id': str(Price), 'name': str(Price)}) return JsonResponse({'data': list})
defPriceSelected(request, id): # When cilcking on a price, get the stape Price = ITEM_CATEGORY.loc[int(id), 'PRICE'] Staple = ITEM_CATEGORY[(ITEM_CATEGORY['ITEM_CATEGORY'] == 'Staple') & (ITEM_CATEGORY['PRICE'] == Price)] list = [] for index in Staple.index: list.append({'id': str(index), 'name': str(Staple.loc[index, 'ITEM_DESCRIPTION'])}) return JsonResponse({'data': list})