当前位置: 首页>>代码示例>>Python>>正文


Python Todo.save方法代码示例

本文整理汇总了Python中models.Todo.save方法的典型用法代码示例。如果您正苦于以下问题:Python Todo.save方法的具体用法?Python Todo.save怎么用?Python Todo.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Todo的用法示例。


在下文中一共展示了Todo.save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: add

# 需要导入模块: from models import Todo [as 别名]
# 或者: from models.Todo import save [as 别名]
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'))
开发者ID:LiangCY,项目名称:flask_get_started,代码行数:9,代码来源:views.py

示例2: addtodo

# 需要导入模块: from models import Todo [as 别名]
# 或者: from models.Todo import save [as 别名]
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/')
开发者ID:baituhuangyu,项目名称:todolist,代码行数:33,代码来源:views.py

示例3: add_todo

# 需要导入模块: from models import Todo [as 别名]
# 或者: from models.Todo import save [as 别名]
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'))
开发者ID:ryangavin,项目名称:stevens_hackny2011,代码行数:9,代码来源:views.py

示例4: add

# 需要导入模块: from models import Todo [as 别名]
# 或者: from models.Todo import save [as 别名]
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)
开发者ID:atomminder,项目名称:flask_examples,代码行数:10,代码来源:views.py

示例5: add

# 需要导入模块: from models import Todo [as 别名]
# 或者: from models.Todo import save [as 别名]
def add():
   form = request.form
   content = form['content']
   todo = Todo(content = content)
   todo.save()

   todos = Todo.objects.all()
   return render_template("index.html",todos)
开发者ID:namebryant,项目名称:flask_demo,代码行数:10,代码来源:views.py

示例6: add

# 需要导入模块: from models import Todo [as 别名]
# 或者: from models.Todo import save [as 别名]
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)
开发者ID:RiverAge,项目名称:flask-mongodb,代码行数:10,代码来源:views.py

示例7: submit_word

# 需要导入模块: from models import Todo [as 别名]
# 或者: from models.Todo import save [as 别名]
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'))
开发者ID:nikhilalmeida,项目名称:tagger,代码行数:10,代码来源:views.py

示例8: add

# 需要导入模块: from models import Todo [as 别名]
# 或者: from models.Todo import save [as 别名]
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)
开发者ID:NCZkevin,项目名称:Darkwave,代码行数:10,代码来源:views.py

示例9: addTodo

# 需要导入模块: from models import Todo [as 别名]
# 或者: from models.Todo import save [as 别名]
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))
开发者ID:mjcuva,项目名称:ConnectedWire,代码行数:11,代码来源:dashboard.py

示例10: add

# 需要导入模块: from models import Todo [as 别名]
# 或者: from models.Todo import save [as 别名]
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)
开发者ID:ShujiaHuang,项目名称:awesome-flask-todo,代码行数:11,代码来源:views.py

示例11: add

# 需要导入模块: from models import Todo [as 别名]
# 或者: from models.Todo import save [as 别名]
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('/')
开发者ID:ppyadav,项目名称:donita,代码行数:12,代码来源:views.py

示例12: addtodo

# 需要导入模块: from models import Todo [as 别名]
# 或者: from models.Todo import save [as 别名]
def addtodo(request):
	if request.method == 'POST':
		todo = request.POST['todo']
		priority = request.POST['priority']
		user = User.objects.get(id=1)
		addtodo = Todo(user=user, todo=todo, priority=priority, flag='1')
		addtodo.save()
		todolist = Todo.objects.filter(flag=1)
		finishtodos = Todo.objects.filter(flag=0)
		return HttpResponseRedirect("/todolists/")
开发者ID:zhuweiping,项目名称:TodoList,代码行数:12,代码来源:views.py

示例13: testAlterTodo

# 需要导入模块: from models import Todo [as 别名]
# 或者: from models.Todo import save [as 别名]
 def testAlterTodo(self):
     todo = Todo()
     todo.text = "Get some milk"
     todo.timestamp = datetime.now()
     todo.save()
     
     assert not todo.completed
     todo.completed = True
     todo.save()
     
     assert todo.completed
开发者ID:andymckay,项目名称:cleardjango,代码行数:13,代码来源:tests.py

示例14: add_todo

# 需要导入模块: from models import Todo [as 别名]
# 或者: from models.Todo import save [as 别名]
def add_todo(request):
    t = Todo( # Creates new todo
        title = request.POST['title'],
        description = request.POST['description'],
        importance = request.POST['importance'],
        start_date = request.POST['start_date'],
        stop_date = request.POST['stop_date'],
        owner = request.user)
    t.save()
    # reverse() takes etiher a view or the name of a view and returns its URLS:
    return HttpResponseRedirect(reverse(todo_index)) # Redirect todo_index view 
开发者ID:pombredanne,项目名称:denigma,代码行数:13,代码来源:views.py

示例15: create

# 需要导入模块: from models import Todo [as 别名]
# 或者: from models.Todo import save [as 别名]
def create(request):
    req = simplejson.loads(request.raw_post_data)
    content = req['content']
    order = req['order']
    
    if not content:
        return HttpResponse(simplejson.dumps({'success':False}), mimetype = 'application/json')
    todo = Todo()
    todo.content = content
    todo.order = order
    todo.save()
    return HttpResponse(simplejson.dumps({'success':True}), mimetype = 'application/json')
开发者ID:eetuuuu,项目名称:the5fire-servertodos,代码行数:14,代码来源:views_todos.py


注:本文中的models.Todo.save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。