Nested blueprints should be able to have the same name. Currently all blueprints are registered under their own name, however for a nested blueprint id expected it to use the <parent_name>.<child_name>
from pprint import pprint
import flask
app = flask.Flask(__name__)
view_bp = flask.Blueprint("home", __name__)
api_bp = flask.Blueprint("api", __name__, url_prefix="/api")
home_api_bp = flask.Blueprint("home", __name__)
@view_bp.route("/")
@home_api_bp.route("/")
def view():
print(flask.request, flask.request.endpoint)
api_bp.register_blueprint(home_api_bp)
app.register_blueprint(view_bp)
app.register_blueprint(api_bp)
pprint(app.url_map)
Traceback (most recent call last):
File "/home/maico/test.py", line 18, in <module>
app.register_blueprint(api_bp)
File "/home/maico/.local/lib/python3.9/site-packages/flask/scaffold.py", line 54, in wrapper_func
return f(self, *args, **kwargs)
File "/home/maico/.local/lib/python3.9/site-packages/flask/app.py", line 1023, in register_blueprint
blueprint.register(self, options)
File "/home/maico/.local/lib/python3.9/site-packages/flask/blueprints.py", line 359, in register
blueprint.register(app, bp_options)
File "/home/maico/.local/lib/python3.9/site-packages/flask/blueprints.py", line 275, in register
assert app.blueprints[self.name] is self, (
AssertionError: A name collision occurred between blueprints <Blueprint 'home'> and <Blueprint 'home'>. Both share the same name 'home'. Blueprints that are created on the fly need unique names.
Nested blueprints should be able to have the same name. Currently all blueprints are registered under their own name, however for a nested blueprint id expected it to use the
<parent_name>.<child_name>Environment: