I am creating a gym website for a project and I am getting this error:
werkzeug.routing.BuildError: Could not build url for endpoint 'memberships'. Did you mean 'membershipsub' instead?
I had created a template called 'memberships' initially and renamed it to 'membershipsub' after getting this error (everywhere in all the files it was referenced) and still get this error.
This is my code for the building of the template:
@app.route("/memberships", methods = ['GET', 'POST'])
def membershipsub():
form = MembershipsubForm()
plan1 = Membership_plan.query.filter_by(id=1).first()
plan2 = Membership_plan.query.filter_by(id=2).first()
plan3 = Membership_plan.query.filter_by(id=3).first()
plan4 = Membership_plan.query.filter_by(id=4).first()
plan5 = Membership_plan.query.filter_by(id=5).first()
plan6 = Membership_plan.query.filter_by(id=6).first()
plan7 = Membership_plan.query.filter_by(id=7).first()
plan8 = Membership_plan.query.filter_by(id=8).first()
plan9 = Membership_plan.query.filter_by(id=9).first()
if form.validate_on_submit():
age18 = ['18+ year', '18+ 6 month', '18+ month']
age15 = ['15-17 year', '15-17 6 month', '15-17 month']
age10 = ['10-14 year', '10-14 6 month', '10-14 month']
if not (current_user.is_authenticated):
flash('You need to have an account to subscribe to a membership', 'danger')
return redirect(url_for('register'))
elif (current_user.age >= 18) and (form.membershipsub.data not in age18):
flash('You are not in the required age category to subscribe to this membership or this membership option is not available', 'danger')
elif (14 < current_user.age < 18) and (form.membershipsub.data not in age15):
flash('You are not in the required age category to subscribe to this membership or this membership option is not available', 'danger')
elif (9 < current_user.age < 15 ) and (form.membershipsub.data not in age10):
flash('You are not in the required age category to subscribe to this membership or this membership option is not available', 'danger')
else:
current_user.membership_plan = form.membershipsub.data
current_user.membership_expiration_date = membership_expiration()
db.session.commit()
flash('You have now subscribed to this membership!', 'success')
return redirect(url_for('mymembership'))
return render_template('membershipsub.html', title='Memberships', form=form, plan1=plan1, plan2=plan2, plan3=plan3, plan4=plan4, plan5=plan5, plan6=plan6, plan7=plan7, plan8=plan8, plan9=plan9)
Also, I am not using blueprints so that isn't the issue.