- #1
rgtr
- 92
- 8
- TL;DR Summary
- jinja2.exceptions.TemplateSyntaxError: invalid syntax for function call expression The line above is some of the code in profile.html This happens when I click on the profile link.
This is in python flask. I am getting an error
line 16, in template
jinja2.exceptions.TemplateSyntaxError: invalid syntax for function call expression The line above is some of the code in profile.html This happens when I click on the profile link. How do I fix this?
routes.py
profile route
update profile route
line 16, in template
html code:
<h2> <a href="{{ url_for('userinfo.profile', username=current_user.username, 'update_profile') }}"> update_profile_info </a> </h2>
routes.py
profile route
python flask:
@userinfo.route('/profile/<string:username>', methods = ['GET'])
def profile(username):
user = User.query.filter_by(username=username).first_or_404()
# profilepicture = request.files['profilepicture']
posts = Posts.query.filter_by(id=current_user.id).first()
return render_template('profile.html', title='profile', username=user.username, post_id=posts.post_id)
flask python:
@login_required
@userinfo.route("/profile/<string:username>/update_profile", methods = ['POST','GET'] )
def update_profile(username):
form = UpdateAccountForm if form.validate_on_submit():
# do I need this line? Yes to make sure the username exists.
username = User.query.filter_by(username=username).first_or_404()
password = form.password.data
confirm_password = form.confirm_password
# should I get the hashed passwords before checking them?
if password != confirm_password:
# need better phrasing
flash("Your passwords fields don't match.")
else:
hashed_password = bcrypt.hashpw(password.encode('utf-8'), bcrypt.gensalt())
# user = User.query.filter_by(hashed_password='hashed_password').first()
user = User(hashed_password=hashed_password)
db.session.add(user)
db.session.commit()
Last edited: