本文整理汇总了Python中models.Team.image_url方法的典型用法代码示例。如果您正苦于以下问题:Python Team.image_url方法的具体用法?Python Team.image_url怎么用?Python Team.image_url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Team
的用法示例。
在下文中一共展示了Team.image_url方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_team
# 需要导入模块: from models import Team [as 别名]
# 或者: from models.Team import image_url [as 别名]
def add_team():
if 'user_id' in session:
user_id = session['user_id']
user = User.query.get(user_id)
else:
return redirect(url_for('index'))
if request.method == 'POST':
team = Team(title = request.form['title'],
intro = request.form['intro'])
image_url = request.form['image_url']
if image_url:
team.image_url = image_url
else:
team.image_url = app.config['DEFAULT_TEAM_IMG']
team.admins.append(user)
user.teams.append(team)
db.session.add(team)
db.session.commit()
# add tags
add_tags = request.form['tags'].split(',')
for t in add_tags:
t = t.strip()
if Tag.query.filter_by(title=t).count() == 0 and t:
new_t = Tag(title = t)
db.session.add(new_t)
team.tags.append(new_t)
db.session.commit()
return redirect(url_for('profile'))
return render_template('add_team.html',
title = 'add_team')