本文整理汇总了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))
示例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)
示例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)
示例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)
示例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'))
示例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)
示例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)
示例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)