Skip to content
This repository has been archived by the owner on Nov 19, 2017. It is now read-only.
Noah K. Tilton edited this page May 13, 2016 · 1 revision

Welcome to the flask-navigation wiki!

# pull records from a database (sqlalchemy) into Flask-Navigation:
#
# Flask-Navigation (nav)

def get_items(node, L):
    def i(s):
        d = [i(c) for c in s.children]
        return nav.Item(s.title, 'page', {'slug' : s.slug}, items=d)
    for c in node.children:
        L.append(i(c))
    return L

with app.app_context():
    root = Nav.query.filter(Nav.parent_id.is_(None)).first()
    nav.Bar('top', get_items(root, []))
Clone this wiki locally