Skip to content

url_for can't distinguish a blueprint mounted two times #1091

@iurisilvio

Description

@iurisilvio

Based on blueprint concept, I expected it to handle relative url_for nicely:

from flask import Blueprint, Flask, url_for

bp = Blueprint('foo', __name__)

@bp.route('/')
def func():
    return url_for('.func')

app = Flask(__name__)
app.register_blueprint(bp, url_prefix='/foo')
app.register_blueprint(bp, url_prefix='/bar')

client = app.test_client()
print client.get('/foo/').data
print client.get('/bar/').data

Both prints write the URL to the first blueprint registered (/foo/). Is it possible to mount two times the same blueprint and make relative url_for work? Is this behaviour expected?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions