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


Python models.Todo类代码示例

本文整理汇总了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'))
开发者ID:LiangCY,项目名称:flask_get_started,代码行数:7,代码来源:views.py

示例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/')
开发者ID:baituhuangyu,项目名称:todolist,代码行数:31,代码来源:views.py

示例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'))
开发者ID:ryangavin,项目名称:stevens_hackny2011,代码行数:7,代码来源:views.py

示例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)
开发者ID:RiverAge,项目名称:flask-mongodb,代码行数:8,代码来源:views.py

示例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)
开发者ID:robi42,项目名称:backbone-flask,代码行数:8,代码来源:app.py

示例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'))
开发者ID:nikhilalmeida,项目名称:tagger,代码行数:8,代码来源:views.py

示例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)
开发者ID:namebryant,项目名称:flask_demo,代码行数:8,代码来源:views.py

示例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)
开发者ID:atomminder,项目名称:flask_examples,代码行数:8,代码来源:views.py

示例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)
开发者ID:NCZkevin,项目名称:Darkwave,代码行数:8,代码来源:views.py

示例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)
开发者ID:MongoEngine,项目名称:flask-mongoengine,代码行数:9,代码来源:views.py

示例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)
开发者ID:adamchainz,项目名称:flask-mongoengine,代码行数:9,代码来源:views.py

示例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")
开发者ID:filippotocnik,项目名称:todo,代码行数:9,代码来源:main.py

示例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)
开发者ID:ShujiaHuang,项目名称:awesome-flask-todo,代码行数:9,代码来源:views.py

示例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))
开发者ID:mjcuva,项目名称:ConnectedWire,代码行数:9,代码来源:dashboard.py

示例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('/')
开发者ID:ppyadav,项目名称:donita,代码行数:10,代码来源:views.py


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