Beispiel #1
0
 def post(self, request):
     try:
         print ">>>request.POST", request.POST
         food_img = request.POST["food_img"]  # 菜图片
         food_price = request.POST["food_price"]  # 菜价格
         food_name = request.POST["food_name"]  # 菜名字
         food_desc = request.POST["food_desc"]  # 活动配图
         group_id = request.POST["group_id"]  # 分组id
         food_id = rand_str(8)
         food = Food()
         food.food_id = food_id
         food.name = food_name
         food.group_id = group_id
         food.food_img = food_img
         food.desc = food_desc
         food.price = food_price
         food.create_time = datetime.now()
         food.save()
         return JsonResponse({"status": 200, "data": request.POST})
     except BaseException, e:
         return JsonResponse({"error": str(e), "status": 400})