def new_service(request): try: name = request.POST.name return create_service(request.POST) except: try: name = request.BODY['name'] return create_service(request.BODY) except: try: name = json.loads(request.BODY)['name'] return create_service(json.loads(request.BODY)) except: return HttpResponseBadRequest
def form_new_service(request): try: if request.is_authenticated: return create_service(request.FORM) else: return HttpResponseForbidden except: return HttpResponseBadRequest