# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.shortcuts import render
from django.http import HttpResponse

from bson.json_util import dumps
from pymongo import MongoClient

client = MongoClient('mongodb://localhost:27017')
db = client['ta_sas']
UserClassifyIdCollection = db['UserClassifyId']

# Create your views here.


def studentList(request):
    students = list(UserClassifyIdCollection.find())
    response = HttpResponse(dumps(students, sort_keys=True), content_type="application/json")
    response['Access-Control-Allow-Origin'] = 'http://localhost:3000'
    return response

@@ -346,16 +346,88 @@
  here.%0A%0A
+def mapObject(obj):%0A    obj%5B'_id'%5D = str(obj.get('_id'))%0A    return obj%0A
 %0Adef stu
@@ -498,16 +498,71 @@
 find())%0A
+    convertedStudents = list(map(mapObject, students))%0A
     resp
@@ -587,17 +587,26 @@
 e(dumps(
-s
+convertedS
 tudents,

Convert ObjectId to String