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)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sqlalchemy-nav-0.0.5.tar.gz | 4.8 kB | Without provenance | Details for sqlalchemy-nav-0.0.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sqlalchemy_nav-0.0.5-py3-none-any.whl | Python 3 | none | any | Details for sqlalchemy_nav-0.0.5-py3-none-any.whl |
Total release size: 14.8 kB
Security for sqlalchemy-nav 0.0.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.