def add_ranking(request): """ 添加榜单 :param request: :return: """ if request.method == "POST": try: _table = { "name_cn": request.POST["table_name_cn"], "type": 1 } # 榜单 _fields = request.POST.getlist("field_name_cn") table_id = Table.create_table(_table, _fields) if table_id: return HttpResponseRedirect("/backend/ranking/" + str(table_id) + "/") else: raise Exception("Add Ranking Failed") except Exception as e: logger.error(str(e)) messages.error(request, "添加榜单失败") urls = copy.deepcopy(SIDEBAR_URL) urls[3]["active"] = True return render(request, "backend/ranking/add.html", { "self": request.user, "urls": urls })
def test3(request): result = [] tables = {"table_name": "test", "table_name_cn": "啊", "table_type": 1} fields = [{"field_name": "test", "field_name_cn": "啊啊", "field_type": 1}] result = Table.create_table(tables, fields) return HttpResponse(json.dumps(result))