GeniePy comes with built-in support for enabling an internal admin interface backed by sqladmin.

Description

An internal admin interface lets you quickly manage database records in your application so that (almost) everyone at the company can make edits without requiring any developer effort of any kind.

GeniePy uses the sqladmin open-source library to give you an internal admin interface out of the box.

Setup

No setup is required. The admin interface is readily accessible at http://localhost:9001/admin and restricted to staff users.

Configuration

All the admin interface configuration lives inside the app/admin/ package.

If you've added a new database table and would like to register it in the admin interface, you would need to configure an admin class for it by adding a new Python module (file) in the app/admin/ directory.

Here's an example configuration for a SubscriptionPlan model:

from app.admin import BaseModelView
from app.models.subscription_plan import SubscriptionPlan


class SubscriptionPlanAdminView(BaseModelView, model=SubscriptionPlan):
    pass

You can further change its behavior according to the sqladmin configuration options.

After defining the AdminView class, register it with the admin interface inside app/main.py:

# Starlette

instance = Starlette(...)

# Admin
admin = Admin(instance, make_engine())
admin.add_view(SubscriptionPlanAdminView)

And that's all the configuration you need.