post接收字符串def subscription(request):msg = request.POST.get(msg)# tel_no = request.POST.get(tel_no)# email = request.POST.get(email)# ico_id = request.POST.get(ico_id)data = base64.b64decode(msg)data = data.decode(utf-8)data = json.loads(data)client = pymongo.MongoClient(host = localhost,port = 27017)db = client.usersmy_set = db.userif ico_id not in data.keys():return HttpResponse(json.dumps({"...
Django查询表数据转换成JSON格式 直接利用python提供的json包,在django model的定义中增加一个方法toJSON,利用django model 能访问 _meta.fields 得到相关属性而得到,例子如下: model层: class StudentInfo(models.Model):stu_id = models.CharField(primary_key=True, max_length=20)stu_name = models.CharField(max_length=20)stu_password = models.CharField(max_length=20)def __unicode__(self):return '%s' % self.st...