@require_POST
def add_tag(request):
  response = {'status': -1, 'message': ''}

  try:
    validstatus = valid_project(name=request.POST['name'])
    if validstatus:
      tag = DocumentTag.objects.create_tag(request.user, request.POST['name'])
      response['name'] = request.POST['name']
      response['id'] = tag.id
      response['docs'] = []
      response['owner'] = request.user.username
      response['status'] = 0
    else:
      response['status'] = -1
  except __HOLE__, e:
    response['message'] = _('Form is missing %s field') % e.message
  except Exception, e:
    response['message'] = force_unicode(e)

  return JsonResponse(response)
dataset/ETHPy150Open cloudera/hue/desktop/core/src/desktop/api.py/add_tag