- return HttpResponse(json.dumps({'error' : 'only post request is supported'}), content_type="application/json")
-
- query = Query.create(object_type)
+ #return error('only post request is supported')
+ req_items = request.GET
+ for el in list(req_items.items()):
+ # Filters not used for create
+ if el[0].startswith('filters'):
+ o.filters[el[0][8:-1]] = el[1]
+ elif el[0].startswith('params'):
+ #o.params[el[0][7:-1]] = el[1]
+ o.params.append({el[0][7:-1]:el[1]})
+ elif el[0].startswith('fields'):
+ o.fields=req_items.getlist('fields[]')
+ elif el[0].startswith('options'):
+ o.options = req_items.getlist('options[]')
+
+ try:
+ response = o.create()
+
+ if response :
+ return success('record created')
+ else :
+ return error('an error has occurred')
+
+ except Exception as e:
+ return error(str(e))