Skip to main content

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.

Installation

$ pip install sqlalchemy-nav

Quickstart

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)
Base.metadata.create_all(engine)

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')
session.add(navbar)
session.commit()
print(navbar.render().prettify())

Out:

<nav class="navbar navbar-expand-lg navbar-light bg-light fixed-top">
 <a class="navbar-brand" href="https://my-home-page">
  Home
 </a>
 <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">
  </span>
 </button>
 <div class="collapse navbar-collapse" id="navbar-1">
  <ul class="navbar-nav mr-auto">
   <li class="nav-item">
    <a class="nav-link" href="/about">
     About
    </a>
   </li>
   <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">
     Dropdown
    </a>
    <div aria-labelledby="navitem-2" class="dropdown-menu">
     <a class="dropdown-item" href="/item0">
      Item0
     </a>
     <a class="dropdown-item" href="/item1">
      Item1
     </a>
    </div>
   </li>
  </ul>
 </div>
</nav>

Citation

@software{bowen2020sqlalchemy-nav,
  author = {Dillon Bowen},
  title = {SQLAlchemy-Nav},
  url = {https://dsbowen.github.io/sqlalchemy-nav/},
  date = {2020-06-10},
}

License

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

It is licensed with the MIT License.

Metadata

Release files for sqlalchemy-nav 0.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sqlalchemy-nav 0.0.5
File Size Uploaded
sqlalchemy-nav-0.0.5.tar.gz 4.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sqlalchemy-nav 0.0.5
File Interpreter ABI Platform
sqlalchemy_nav-0.0.5-py3-none-any.whl Python 3 none any Details

Total release size: 14.8 kB

Release files / sqlalchemy-nav-0.0.5.tar.gz

Download URL sqlalchemy-nav-0.0.5.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
95389d066f013b2caf11d611de6296c6b2ca3c071a1b8403127e0cdb6f3eb2f3
BLAKE2b-256 checksum
How to use checksums
8a331c9ff59475b13b93a7ee2820ba2a1c9d993c8d0cfe55de90250375a83205
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.8

Release files / sqlalchemy_nav-0.0.5-py3-none-any.whl

Download URL sqlalchemy_nav-0.0.5-py3-none-any.whl
Size 10.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9e2a64f8fd74be85b518c296c9188de64ec306b7b30a224cd19a2465c306a3de
BLAKE2b-256 checksum
How to use checksums
1460ec00e5a558132d43c86dd370b35b9c74475d82a750646d7d554c8be5bb19
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.8

Release history Release notifications | RSS feed

This release

0.0.5 This release

2 release files

0.0.4

1 release file

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page