python - Flask werkzeug.routing.BuildError -
i doing flask app , when try put link redirect user profile page calling
builderror: not build url endpoint 'profile'. did forget specify values ['business_name']?
when try login user.my app works fine previous days same code not has happen , have tried possible means right no way
@app.route('/profile/<business_name>') @login_required def profile(business_name): user = user.query.filter_by(business_name=business_name).first() if user == none: flash('this profile not exist {}'.format(business_name)) return redirect(url_for('login')) return render_template('profile.html',user=user)
(main.html)
<ul class="nav navbar-nav"> <li><a href="{{ url_for('home_page') }}" class="active">home</a></li> {% if g.user.is_authenticated %} <li><a href="{{ url_for('profile', business_name=g.user.business_name) }}">your profile</a></li> <li><a href="{{url_for('logout')}}">logout</a></li>
problem not defining route view function take in following form:
/profile/business_name
hence should send business_name in url sending arguments function. should following:
<a href="/profile/{{business_name=g.user.business_name }}">
Comments
Post a Comment