parameters: (req, id)
return_statement: return HttpResponse(json.dumps(response), content_type="application/json", status=200)
docstring: delete favorite and put favorite_info object in response.
      method is idempotent, if favorite does not exist, just return favorite_info.
docstring_summary: delete favorite and put favorite_info object in response.
      method is idempotent, if favorite does not exist, just return favorite_info.
docstring_tokens: delete favorite and put favorite_info object in response . method is idempotent if favorite does not exist just return favorite_info .
function: def delete_favorite(req, id):
      """
      delete favorite and put favorite_info object in response.
      method is idempotent, if favorite does not exist, just return favorite_info.
      """
      try:
          favorite = models.Favorite.objects.get(user=req.user, pk=id)
          favorite.delete()
      except ObjectDoesNotExist:
          pass
  
      response = {"has_favorite": "false"}
  
      return HttpResponse(json.dumps(response), content_type="application/json", status=200)
function_tokens: def delete_favorite ( req , id ) : try : favorite = models . Favorite . objects . get ( user = req . user , pk = id ) favorite . delete ( ) except ObjectDoesNotExist : pass response = { "has_favorite" : "false" } return HttpResponse ( json . dumps ( response ) , content_type = "application/json" , status = 200 )