def getParts(request): try: data = json.loads(request.body) try: token = Token.objects.filter(token=data['token']).first() user = token.user except: raise myError('Please Log In.') part_name = data['part_name'] searchResult = getPart(part_name) if searchResult['successful']: result = { 'successful': True, 'data': searchResult, 'error': { 'id': '', 'msg': '', } } else: raise myError('Check Failed.') except myError, e: result = { 'successful': False, 'error': { 'id': '', 'msg': e.value, } }
def getParts(request): partName = request.GET.get('partname') results = getPart(partName) return HttpResponse(json.dumps(results), content_type="text/json")