本文整理汇总了Python中models.Todo类的典型用法代码示例。如果您正苦于以下问题:Python Todo类的具体用法?Python Todo怎么用?Python Todo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Todo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add
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'))
示例2: addtodo
def addtodo(request):
if 'Item' in request.GET and request.GET['Item']:
newname = request.GET['Item']
newstatue = '0'
# print('1')
newid = Todo.objects.order_by('id').reverse()[0].id+1
todo = Todo(id=newid, name=newname, statue=newstatue)
todo.save()
# NOtE:重定向至首页,安全一些
return HttpResponseRedirect('/index/')
##or:发送请求至首页与重定向有区别
# return index(request)
# notlist = Todo.objects.filter(statue=0)
# finishlist = Todo.objects.filter(statue=1)
# notpaginator = Paginator(notlist, 3)
# finishpaginator = Paginator(finishlist, 3)
# try:
# anotpage = int(request.GET.get('notpage', 1))
# afinishpage = int(request.GET.get('finishpage', 1))
# nottodo = notpaginator.page(anotpage)
# finish = finishpaginator.page(afinishpage)
# # print(Todo.objects.order_by('id').reverse()[0].id + 1)
# except (EmptyPage, InvalidPage, PageNotAnInteger):
# nottodo = notpaginator.page(1)
# finish = finishpaginator.page(1)
# return render_to_response('index.html',
# {'nottodo': nottodo, 'finish': finish},
# context_instance=RequestContext(request))
else:
return HttpResponseRedirect('/index/')
示例3: add_todo
def add_todo():
"""Add a todo."""
form = TodoForm()
if request.method == 'POST' and form.validate_on_submit():
todo = Todo(text=form.todo.data)
todo.save()
return redirect(url_for('todo_list'))
示例4: add
def add():
content = request.form.get("content")
status = request.form.get("status")
todo = Todo(content=content, status=status)
todo.save()
# return redirect("/")
todos = Todo.objects.all()
return render_template("index.html", todos=todos)
示例5: create_todo
def create_todo():
data = json.loads(request.data)
todo = Todo(content=data['content'], done=data['done'], order=data['order'])
todo.put()
return jsonify(id=todo.key().id(),
content=todo.content,
done=todo.done,
order=todo.order)
示例6: submit_word
def submit_word(user_id):
"""Add a todo."""
form = TodoForm()
if request.method == 'POST' and form.validate_on_submit():
todo = Todo(text=form.todo.data)
todo.save()
return redirect(url_for('game_list'))
示例7: add
def add():
form = request.form
content = form['content']
todo = Todo(content = content)
todo.save()
todos = Todo.objects.all()
return render_template("index.html",todos)
示例8: add
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)
示例9: add
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)
示例10: pagination
def pagination():
Todo.objects().delete()
for i in range(10):
Todo(title='Simple todo {}'.format(i), text="12345678910").save() # Insert
page_num = int(flask.request.args.get('page') or 1)
todos_page = Todo.objects.paginate(page=page_num, per_page=3)
return flask.render_template('pagination.html', todos_page=todos_page)
示例11: index
def index():
# As a list to test debug toolbar
Todo.objects().delete() # Removes
Todo(title="Simple todo A", text="12345678910").save() # Insert
Todo(title="Simple todo B", text="12345678910").save() # Insert
Todo.objects(title__contains="B").update(set__text="Hello world") # Update
todos = list(Todo.objects[:10])
todos = Todo.objects.all()
return flask.render_template('index.html', todos=todos)
示例12: post
def post(self):
task = self.request.get("task")
task = self.validation(task)
task = Todo(task=task)
task.put()
return self.render_template("sporocilo-poslano.html")
示例13: add
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)
示例14: addTodo
def addTodo(request):
todoText = request.GET.get('item')
todo = Todo(text = todoText)
todo.save()
return render_to_response('dashboard/todo.html', {'todoItem':todo}, context_instance =RequestContext(request))
示例15: add
def add(request):
if request.method =='POST':
try:
action = request['action']
print 'action is:', action
except:
return HttpResponseRedirect('/')
item = Todo(action=action, status=False, user=request.user)
item.save()
return HttpResponseRedirect('/')