Skip to main content

Admin interface for Muffin Framework

Project description

Muffin-Admin – an extension to Muffin that implements admin-interfaces

Tests Status PYPI Version Python Versions



  • python >= 3.7


Muffin-Admin should be installed using pip:

pip install muffin-admin

With SQLAlchemy Core support:

pip install muffin-admin[sqlalchemy]

With Peewee ORM support:

pip install muffin-admin[peewee]


Initialize the admin:

from muffin_admin import Plugin

admin = Plugin(**options)

Initialize admin handlers (example for Peewee ORM):

from muffin_admin import PWAdminHandler

 class UserResource(PWAdminHandler):

     """Create Admin Resource for the User model."""

     class Meta:

         """Tune the resource."""

         # Peewee Model for the admin resource
         model = User

         # Filters
         filters = 'email', 'created', 'is_active', 'role'

         # Tune serialization/deserialization schemas
         schema_meta = {
             'load_only': ('password',),
             'dump_only': ('created',),

         # Columns to show
         columns = 'id', 'email', 'is_active', 'role', 'created'

         # Custom Material-UI icon
         icon = 'People'

Connect admin to an Muffin application:

admin.setup(app, **options)


Decorate an authentication function with admin.check_auth:

async def auth(request):
    """Fake authorization method. Just checks for an auth token exists in request."""
    return request.headers.get('authorization')

Register a function to return user’s information:

async def ident(request):
    """Get current user information."""
    pk = request.headers.get('authorization')
    user = == pk).first()
    if user:
        return {"id":, "fullName":}

Implement a login handler for standart react-admin auth page:

async def login(request):
    """Login a user."""
    data = await
    user = == data['username'], User.password == data['password']).first()
    return ResponseJSON(user and

For futher reference check <examples> in the repository.

Custom Actions

from muffin_admin import PWAdminHandler

 class UserResource(PWAdminHandler):

     # ...

     @PWAdminHandler.action('users/disable', view='list')
     async def disable_users(self, request, resource=None):
         ids = request.query.getall('ids')
         # ...

     @PWAdminHandler.action('users/{id}/admin', view='show')
     async def mark_admin(self, request, resource=None):
         # ...

Configuration options

Name Default value Description
prefix "/admin" Admin’s HTTP URL prefix
title "Muffin Admin" Admin’s title
main_js_url "{prefix}/main.js" A link to main JS file
custom_js_url "" A link to custom JS file
custom_css_url "" A link to custom CSS file
logout_url None An HTTP URL for your custom logout page
auth_storage "localstorage" Where to keep authorization information (localstorage|cookies)
auth_storage_name muffin_admin_auth Localstorage/Cookie name for authentication info
app_bar_links [{'url': '/', 'icon': 'Home', 'title': 'Home'}] Appbar links

Bug tracker

If you have any suggestions, bug reports or annoyances please report them to the issue tracker at


Development of Muffin-Admin happens at:


  • klen (Kirill Klenov)


Licensed under a MIT license.

Project details

Release history Release notifications | RSS feed

Download files

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

Files for muffin-admin, version 1.28.2
Filename, size File type Python version Upload date Hashes
Filename, size muffin_admin-1.28.2-py3-none-any.whl (691.2 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size muffin-admin-1.28.2.tar.gz (689.3 kB) File type Source Python version None Upload date Hashes View

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 Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page