本文整理汇总了Python中models.Article.find_by_author方法的典型用法代码示例。如果您正苦于以下问题:Python Article.find_by_author方法的具体用法?Python Article.find_by_author怎么用?Python Article.find_by_author使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Article
的用法示例。
在下文中一共展示了Article.find_by_author方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: author
# 需要导入模块: from models import Article [as 别名]
# 或者: from models.Article import find_by_author [as 别名]
def author(name):
author_articles = Article.find_by_author(name)
if 'email' in session:
person = Person.query.filter_by(email=session['email']).first()
name = person.firstname
return render_template('author.html', author_articles=author_articles, name=name)
return render_template('author.html', author_articles=author_articles)
示例2: dashboard
# 需要导入模块: from models import Article [as 别名]
# 或者: from models.Article import find_by_author [as 别名]
def dashboard(name):
if 'email' not in session:
return redirect(url_for('index'))
person = Person.query.filter_by(email=session['email']).first()
if name == person.firstname:
articles = Article.find_by_author(name)
return render_template('dashboard.html', articles=articles, person=person, name=name)
return redirect(url_for('index'))
示例3: delete_author
# 需要导入模块: from models import Article [as 别名]
# 或者: from models.Article import find_by_author [as 别名]
def delete_author():
person = Person.query.filter_by(email=session['email']).first()
articles = Article.find_by_author(person.firstname)
for article in articles:
db.session.delete(article)
db.session.delete(person)
db.session.commit()
session.pop('email', None)
return redirect(url_for('index'))