Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def import_object(request):
if request.method == "POST" and request.is_ajax():
id_ = request.POST.get('id', None)
type_ = request.POST.get('type', None)
results = handlers.import_object(request, type_, id_)
if results.get('success', False):
if 'object' in results:
del results['object']
return HttpResponse(json.dumps(results),
content_type="application/json")
else:
return render_to_response('error.html',
{'error': "Must be AJAX."},
RequestContext(request))