我正在使用flask,python,postgres创建一个网站,在该网站上,我已经希望用户已经注册并登录才能创建一组朋友,并将自己作为该特定管理员的位置组。我已经尝试过使用flask-login来执行此操作,也尝试过使用最初的创建用户来执行此操作,但是没有任何想法或遵循的路线对我不起作用?
@ auth_bp.route ("/ Team_create /", methods = ["GET", "POST"])
def Team_create_form ():
form = CreateTeam ()
Userl = User.query.all ()
if form.validate_on_submit ():
Teamname = form.Liga.data
teamm.save ()
login_user (teamm, remember = True)
next_page = request.args.get ('next', None)
if not next_page or url_parse (next_page) .netloc! = '':
next_page = url_for ('public.index')
return redirect (next_page)
@ login_manager.user_loader
def load_user (Computer_id):
return User.get_by_id (int (Computer_id))
class Teams (db.Model):
__tablename__ = 'Teams'
__table_args__ = {'extend_existing': True}
id = db.Column (db.Integer, primary_key = True)
def __init __ (self, ....)
self.Teamname = Teamname
def __repr __ (self):
return f '<Generalinf {self.Teamname}>'
def save (self):
if not self.id:
db.session.add (self)
db.session.commit ()
Could not build url for endpoint 'auth.pequipo'. Did you forget to specify values ['Teamname']?
@ auth_bp.route ("/ My_Team / <Teamname>")
def peteam (Teamname):
invokers = Team.query.filter_by (Teamname = Teamname) .first_or_404 ()
logo = Image (invokers.Teamlogo)
return render_template ("auth / player_interfaces / Team_i.html")