Skip to main content

SQLAlchemy-Nav makes it easy to create and customize dynamic Bootstrap 4 Navbars for web apps with a SQLAlchemy backend.

Project description

SQLAlchemy-Nav makes it easy to create and customize dynamic Bootstrap 4 Navbars for web apps with a SQLAlchemy backend.

Why SQLAlchemy-Nav

Unlike static Navbars, SQLAlchemy-Nav can create personalized Navbars for your users.


$ pip install sqlalchemy-nav


Run the following setup code.

from sqlalchemy_nav import NavbarMixin, NavitemMixin, DropdownitemMixin

from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker, scoped_session
from sqlalchemy.ext.declarative import declarative_base

# session creation (standard)
engine = create_engine('sqlite:///:memory:')
session_factory = sessionmaker(bind=engine)
Session = scoped_session(session_factory)
session = Session()
Base = declarative_base()

# use the SQLAlchemy-Nav Mixins to create database models
class Navbar(NavbarMixin, Base):
    __tablename__ = 'navbar'

class Navitem(NavitemMixin, Base):
    __tablename__ = 'navitem'

class Dropdownitem(DropdownitemMixin, Base):
    __tablename__ = 'dropdownitem'

# create the database (standard)

Create and render a Navbar:

navbar = Navbar(label='Home', href='https://my-home-page')
Navitem(navbar, label='About', href='/about')
navitem = Navitem(navbar, dropdown=True, label='Dropdown')
Dropdownitem(navitem, label='Item0', href='/item0')
Dropdownitem(navitem, label='Item1', href='/item1')


<nav class="navbar navbar-expand-lg navbar-light bg-light fixed-top">
 <a class="navbar-brand" href="https://my-home-page">
 <button aria-controls="navbar-1" aria-expanded="false" aria-label="Toggle navigation" class="navbar-toggler" data-target="#navbar-1" data-toggle="collapse" type="button">
  <span class="navbar-toggler-icon">
 <div class="collapse navbar-collapse" id="navbar-1">
  <ul class="navbar-nav mr-auto">
   <li class="nav-item">
    <a class="nav-link" href="/about">
   <li class="nav-item dropdown">
    <a aria-expanded="false" aria-haspopup="true" class="nav-link dropdown-toggle" data-toggle="dropdown" href="" id="navitem-2" role="button">
    <div aria-labelledby="navitem-2" class="dropdown-menu">
     <a class="dropdown-item" href="/item0">
     <a class="dropdown-item" href="/item1">


  author = {Dillon Bowen},
  title = {SQLAlchemy-Nav},
  url = {},
  date = {2020-06-10},


Users must cite this package in any publications which use it.

It is licensed with the MIT License.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sqlalchemy-nav-0.0.5.tar.gz (4.8 kB view hashes)

Uploaded source

Built Distribution

sqlalchemy_nav-0.0.5-py3-none-any.whl (10.0 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page