def add(): form = TodoForm(request.form) if form.validate(): content = form.content.data todo = Todo(content=content, time=datetime.now()) todo.save() return redirect(url_for('index'))
def add(): form = TodoForm(request.form) if form.validate(): content = form.content.data todo = Todo(content=content,time=datetime.now()) todo.save() todos = Todo.objects.order_by('-time') return render_template("index.html",todos=todos,form=form)
def add(): form = TodoForm(request.form) if form.validate(): content = form.content.data todo = Todo(content=content) todo.save() todos = Todo.objects.order_by('-time') return render_template("index.html", todos=todos, form=form)
def add(): form = TodoForm(request.form) if form.validate(): content = form.content.data todo = Todo(content=content) todo.save() todos = Todo.objects.all() return render_template("index.html", todos=todos, form=form)
def add(): form = TodoForm(request.form) if form.validate(): content = form.content.data todo = Todo(content = content) todo.save() # Show all the list again todos = Todo.objects.order_by('-time') return render_template("index.html", todos = todos, form = form)
def add(): # request传入表单数据 form = TodoForm(request.form) # 表单验证 if form.validate(): # 将表单内容传入 content = form.content.data todo = Todo(content = content, time = datetime.now()) # 保存todo表单 todo.save() todos = Todo.objects.order_by('-time') return render_template('index.html', todos=todos, form=form)
def add(): # print(request.form) form = TodoForm(request.form) # print form.__dict__ if form.validate(): content = form.content.data todo = Todo(content=content, time=datetime.now()) # todo = Todo() # todo.content = content todo.save() todos = Todo.objects.order_by("-time") return render_template("index.html", todos=todos, form=form)
def undone(todo_id): form = TodoForm() todo = Todo.objects.get_or_404(id=todo_id) todo.status = 0 todo.save() todos = Todo.objects.order_by('-time') return render_template("index.html", todos=todos, form=form)
def index(): form = TodoForm() todos = Todo.objects.order_by('-time') return render_template("index.html", todos=todos, form=form, version=app_version())
def delete(todo_id): form = TodoForm() todo = Todo.objects.get_or_404(id=todo_id) todo.delete() todos = Todo.objects.order_by('-time') return render_template("index.html", todos=todos, form=form, version=app_version())
def done(todo_id): form = TodoForm() todo = Todo.objects.get_or_404(id=todo_id) todo.status = 1 todo.save() todos = Todo.objects.order_by('-time') return render_template("index.html", todos=todos, form=form, version=app_version(), hostname=hostname())
def index(): form = TodoForm() todos = Todo.objects.order_by('+time') return render_template("index.html", todos=todos, form=form)
def delete(todo_id): form = TodoForm() todo = Todo.objects.get_or_404(id=todo_id) todo.delete() todos = Todo.objects.order_by('-time') return render_template('index.html',todos=todos,form=form)