flask-breadcrumbs icon indicating copy to clipboard operation
flask-breadcrumbs copied to clipboard

Error with paths, blueprint and more than one route

Open marticardus opened this issue 8 years ago • 0 comments

Hi,

I currently using Flask-Menu to make the menu of my app, and now i want to use Flask-Breadcrumbs to make it more usable but i have a problem.

I changed all decorators of "register_menu" for "register_breadcrumbs" and the menu breaks.

In a app.py i have the base menu like this:

from flask import Flask, render_template
from flask_breadcrumbs import Breadcrumbs, register_breadcrumb

app = Flask(__name__)
Breadcrumbs(app)

@register_breadcrumb(app, '.', 'Home')
@register_breadcrumb(app, '.first', 'First', order=0)
@register_breadcrumb(app, '.second', 'Second', order=1)
@app.route('/')
def index(): return render_template('index.html')

# Loading views
resources_dir = 'views'
import views
for importer, package_name, _ in pkgutil.iter_modules(views.__path__):
    module = importer.find_module(package_name).load_module('%s.%s' % (resources_dir, package_name))
    if hasattr(module, 'bp'):
        try:
            app.register_blueprint(getattr(module, 'bp'))
        except Exception, e:
            pass

In my template i have this code

                        <ol class="breadcrumb">
                           {% for breadcrumb in breadcrumbs %}
                           <li>{{ breadcrumb.text }}</li>
                           {% endfor %}
                        </ol>

And i see this breadcrumb image

As you can see, i have two entris with "Menu item not initialised"

In one of these views i have more child entris of ".erp" submenu that cause this missfunction

@register_breadcrumb(bp, '.erp.config', 'Config')
@register_breadcrumb(bp, '.erp.exec', 'Exec')
@register_breadcrumb(bp, '.erp.report', 'Reports')
@bp.route('/' )

Can you help me?

King regards

marticardus avatar May 04 '17 14:05 marticardus