def add(request): uname = current_user(request) u = User.find_by(username=uname) if request.method == 'POST': form = request.form() t = Todo.new(form) t.user_id = u.id t.save() return redirect('/todo')
def add(request): headers = {'Content-Type': 'text/html'} uname = current_user(request) u = User.find_by(username=uname) if request.method == 'POST': form = request.form() t = Todo.new(form) t.user_id = u.id t.save() return redirect('/todo')
def add(request): """ add 功能 """ headers = { 'Content-Type': 'text/html', } if request.method == 'POST': form = request.form() t = Todo.new(form) # 保存todo到数据库 t.save() # 拿到后端返回的数据后,再重定向到首页,就可以看到新增的数据 return redirect('/todo')
def add(request): form = request.form() Todo.new(form) return redirect('/todo')
def add(): form = request.json if len(form['title']) > 0: form['user_id'] = current_user().id t = Todo.new(form) return jsonify(t.json())