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


Python Article.find_by_id方法代码示例

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


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

示例1: article_delete

# 需要导入模块: from models import Article [as 别名]
# 或者: from models.Article import find_by_id [as 别名]
def article_delete(id, slug):
    article = Article.find_by_id(id)
    person = Person.query.filter_by(email=session['email']).first()
    name = person.firstname
    db.session.delete(article)
    db.session.commit()
    return redirect(url_for('dashboard', name=name))
开发者ID:mitchheard,项目名称:mitchheardcom,代码行数:9,代码来源:views.py

示例2: show_article

# 需要导入模块: from models import Article [as 别名]
# 或者: from models.Article import find_by_id [as 别名]
def show_article(id, slug):
    article = Article.find_by_id(id)
    if 'email' in session:
        person = Person.query.filter_by(email=session['email']).first()
        name = person.firstname
        return render_template('article_show.html', article=article, name=name)
    return render_template('article_show.html', article=article)
开发者ID:mitchheard,项目名称:mitchheardcom,代码行数:9,代码来源:views.py

示例3: update_article

# 需要导入模块: from models import Article [as 别名]
# 或者: from models.Article import find_by_id [as 别名]
def update_article(id,slug):
    article = Article.find_by_id(id)
    if article is None:
        return HTTPNotFound(404)
    form = ArticleUpdateForm(request.form,article)
    if form.validate_on_submit():
        form.populate_obj(article)
        db.session.add(article)
        db.session.commit()
        return redirect(url_for('index'))
    return render_template('create.html',form=form)
开发者ID:bluecliff,项目名称:python-blog,代码行数:13,代码来源:views.py

示例4: article_update

# 需要导入模块: from models import Article [as 别名]
# 或者: from models.Article import find_by_id [as 别名]
def article_update(id, slug):
    article = Article.find_by_id(id)
    if not article:
        return HTTPNotFound(404)
    form = ArticleUpdateForm(request.form, article)
    person = Person.query.filter_by(email=session['email']).first()
    name = person.firstname
    if form.validate_on_submit():
        form.populate_obj(article)
        db.session.add(article)
        db.session.commit()
        return redirect(url_for('index'))
    return render_template('article_create.html', form=form, name=name)
开发者ID:mitchheard,项目名称:mitchheardcom,代码行数:15,代码来源:views.py

示例5: article_delete

# 需要导入模块: from models import Article [as 别名]
# 或者: from models.Article import find_by_id [as 别名]
def article_delete(id):
    article = Article.find_by_id(id)
    if not article:
        return HTTPNotFound(404)

    photos = Photo.find_by_article_id(id)
    for photo in photos:
        photo.delete()

    db.session.delete(article)
    db.session.commit()

    return redirect(url_for('house.all_articles'))
开发者ID:johnedenfield,项目名称:OurHouseBlog,代码行数:15,代码来源:views.py

示例6: article_edit

# 需要导入模块: from models import Article [as 别名]
# 或者: from models.Article import find_by_id [as 别名]
def article_edit(id):
    article = Article.find_by_id(id)
    photos = Photo.find_by_article_id(id)

    if not article:
        return HTTPNotFound()

    form = ArticleEditForm(request.form, article)

    if form.validate_on_submit():
        form.populate_obj(article)

        db.session.add(article)
        db.session.commit()
        return redirect(url_for('house.article_show', id=article.id))
    return render_template('article_edit.html', article=article, photos=photos, form=form)
开发者ID:johnedenfield,项目名称:OurHouseBlog,代码行数:18,代码来源:views.py

示例7: article_show

# 需要导入模块: from models import Article [as 别名]
# 或者: from models.Article import find_by_id [as 别名]
def article_show(id):
    article = Article.find_by_id(id)
    photos = Photo.find_by_article_id(id)

    return render_template('article.html', article=article, photos=photos, user=current_user)
开发者ID:johnedenfield,项目名称:OurHouseBlog,代码行数:7,代码来源:views.py

示例8: show_article

# 需要导入模块: from models import Article [as 别名]
# 或者: from models.Article import find_by_id [as 别名]
def show_article(id,slug):
    article = Article.find_by_id(id)
    return render_template('show_article.html',article=article)
开发者ID:bluecliff,项目名称:python-blog,代码行数:5,代码来源:views.py


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