How do I fix an endpoint error with flask blueprints

前端 未结 1 1061
Happy的楠姐
Happy的楠姐 2021-01-28 22:05

I am learning flask with blueprints and I have the following code example:

from flask import Flask, render_template, Blueprint, g

bp = Blueprint(\'language\', _         


        
相关标签:
1条回答
  • 2021-01-28 22:32

    Looks like you are missing the Blueprint name (language) in your url link:

    From here:

    bp = Blueprint('language', __name__, url_prefix='/<int:language_id>', static_folder='static')
    

    So your link will need to be appended:

    <a href="{{ url_for('language.language', language_id=1) }}">English</a>
    

    I would also suggest naming it something different so it doesn't conflict with any other naming convention you might have.

    0 讨论(0)
提交回复
热议问题