Skip to main content

An admin dashboard.

Project description

An admin dashboard for use with ASGI web frameworks.

Work in progress.

example.py

from starlette.applications import Starlette
from starlette.routing import Mount, Route
from starlette.responses import RedirectResponse
from starlette.templating import Jinja2Templates
from starlette.staticfiles import StaticFiles
import databases
import dashboard
import orm
import datetime


database = databases.Database('sqlite:///test.db')
models = orm.ModelRegistry(database=database)
statics = StaticFiles(packages=['dashboard'])


class Notes(orm.Model):
    registry = models
    tablename = 'notes'
    fields = {
        'id': orm.Integer(title="ID", primary_key=True, read_only=True),
        'created': orm.DateTime(title="Created", default=datetime.datetime.now, read_only=True),
        'text': orm.String(title="Text", max_length=100),
        'completed': orm.Boolean(title="Completed", default=False)
    }

admin = dashboard.Dashboard(tables=[
    dashboard.DashboardTable(ident="notes", title="Notes", datasource=Notes.objects.order_by('-id')),
])


routes = [
    Mount("/admin", app=admin, name='dashboard'),
    Mount("/statics", app=statics, name='static'),
    Route("/", endpoint=RedirectResponse(url='/admin')),
]

app = Starlette(debug=True, routes=routes, on_startup=[database.connect], on_shutdown=[database.disconnect])

Rough installation...

$ virtualenv venv
$ venv/bin/pip install dashboard
$ venv/bin/python
>>> from example import models
>>> models.create_all()
$ venv/bin/uvicorn example:app

With many thanks to Eren Güven (Twitter, GitHub) for the dashboard PyPI package name.

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

dashboard-0.0.5.tar.gz (195.9 kB view details)

Uploaded Source

Built Distribution

dashboard-0.0.5-py3-none-any.whl (201.1 kB view details)

Uploaded Python 3

File details

Details for the file dashboard-0.0.5.tar.gz.

File metadata

  • Download URL: dashboard-0.0.5.tar.gz
  • Upload date:
  • Size: 195.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.6

File hashes

Hashes for dashboard-0.0.5.tar.gz
Algorithm Hash digest
SHA256 a8ada4cdb0364236a11088ad0fb946d7da129bc4d70044ba2a64a34e8eb7f04d
MD5 8bd70a67922e9493f06faed57c8e9e9a
BLAKE2b-256 c46e2c21f67084b399e1bc56e3d1d1a121319705d4001d0feb7580b6ad90a0a4

See more details on using hashes here.

File details

Details for the file dashboard-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: dashboard-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 201.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.6

File hashes

Hashes for dashboard-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 86d47afc70388353de33af3befb5416b69c96a82e1ee516abc3ea0c2362f9b37
MD5 246f56daf0b1850db5e36f632afdbfa1
BLAKE2b-256 9ba9b6cf8bdd104ee84e753289f4c48f513eac7cc0923f08934f066838dabcf4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page