SQLAlchemy Admin for Starlette/FastAPI

Overview

Build Status Publish Status Coverage Package version Supported Python versions


SQLAlchemy Admin for Starlette/FastAPI

SQLAdmin is a flexible Admin interface for SQLAlchemy models.

Main features include:


Documentation: https://aminalaee.github.io/sqladmin

Source Code: https://github.com/aminalaee/sqladmin

Online Demo: Demo


Installation

$ pip install sqladmin

Quickstart

Let's define an example SQLAlchemy model:

from sqlalchemy import Column, Integer, String, create_engine
from sqlalchemy.ext.declarative import declarative_base


Base = declarative_base()
engine = create_engine(
    "sqlite:///example.db",
    connect_args={"check_same_thread": False},
)


class User(Base):
    __tablename__ = "users"

    id = Column(Integer, primary_key=True)
    name = Column(String)


Base.metadata.create_all(engine)  # Create tables

If you want to use SQLAdmin with FastAPI:

from fastapi import FastAPI
from sqladmin import Admin, ModelAdmin


app = FastAPI()
admin = Admin(app, engine)


class UserAdmin(ModelAdmin, model=User):
    column_list = [User.id, User.name]


admin.register_model(UserAdmin)

Or if you want to use SQLAdmin with Starlette:

from sqladmin import Admin, ModelAdmin
from starlette.applications import Starlette


app = Starlette()
admin = Admin(app, engine)


class UserAdmin(ModelAdmin, model=User):
    column_list = [User.id, User.name]


admin.register_model(UserAdmin)

Now visiting /admin on your browser you can see the SQLAdmin interface.

Related projects and inspirations

  • Flask-Admin Admin interface for Flask supporting different database backends and ORMs. This project has inspired SQLAdmin extensively and most of the features and configurations are implemented the same.
  • FastAPI-Admin Admin interface for FastAPI which works with TortoiseORM.
  • Dashboard Admin interface for ASGI frameworks which works with the orm package.
Comments
  • TypeError: Boolean value of this clause is not defined

    TypeError: Boolean value of this clause is not defined

    Checklist

    • [X] The bug is reproducible against the latest release or master.
    • [X] There are no similar issues or pull requests to fix it yet.

    Describe the bug

    Traceback during open 'Create' page (url for example): http://127.0.0.1:8000/admin/user/create

    File "/Users/iuliia_volkova2/Library/Caches/pypoetry/virtualenvs/admin-panel-service-Ji2bEy0B-py3.7/lib/python3.7/site-packages/starlette/templating.py", line 37, in init content = template.render(context) File "/Users/iuliia_volkova2/Library/Caches/pypoetry/virtualenvs/admin-panel-service-Ji2bEy0B-py3.7/lib/python3.7/site-packages/jinja2/environment.py", line 1301, in render self.environment.handle_exception() File "/Users/iuliia_volkova2/Library/Caches/pypoetry/virtualenvs/admin-panel-service-Ji2bEy0B-py3.7/lib/python3.7/site-packages/jinja2/environment.py", line 936, in handle_exception raise rewrite_traceback_stack(source=source) File "/Users/iuliia_volkova2/Library/Caches/pypoetry/virtualenvs/admin-panel-service-Ji2bEy0B-py3.7/lib/python3.7/site-packages/sqladmin/templates/create.html", line 1, in top-level template code {% extends "layout.html" %} File "/Users/iuliia_volkova2/Library/Caches/pypoetry/virtualenvs/admin-panel-service-Ji2bEy0B-py3.7/lib/python3.7/site-packages/sqladmin/templates/layout.html", line 1, in top-level template code {% extends "base.html" %} File "/Users/iuliia_volkova2/Library/Caches/pypoetry/virtualenvs/admin-panel-service-Ji2bEy0B-py3.7/lib/python3.7/site-packages/sqladmin/templates/base.html", line 15, in top-level template code {% block body %} File "/Users/iuliia_volkova2/Library/Caches/pypoetry/virtualenvs/admin-panel-service-Ji2bEy0B-py3.7/lib/python3.7/site-packages/sqladmin/templates/layout.html", line 49, in block 'body' {% block content %} {% endblock %} File "/Users/iuliia_volkova2/Library/Caches/pypoetry/virtualenvs/admin-panel-service-Ji2bEy0B-py3.7/lib/python3.7/site-packages/sqladmin/templates/create.html", line 18, in block 'content' {{ field() }} File "/Users/iuliia_volkova2/Library/Caches/pypoetry/virtualenvs/admin-panel-service-Ji2bEy0B-py3.7/lib/python3.7/site-packages/wtforms/fields/core.py", line 172, in call return self.meta.render_field(self, kwargs) File "/Users/iuliia_volkova2/Library/Caches/pypoetry/virtualenvs/admin-panel-service-Ji2bEy0B-py3.7/lib/python3.7/site-packages/wtforms/meta.py", line 64, in render_field return field.widget(field, **render_kw) File "/Users/iuliia_volkova2/Library/Caches/pypoetry/virtualenvs/admin-panel-service-Ji2bEy0B-py3.7/lib/python3.7/site-packages/wtforms/widgets/core.py", line 174, in call kwargs["value"] = field._value() File "/Users/iuliia_volkova2/Library/Caches/pypoetry/virtualenvs/admin-panel-service-Ji2bEy0B-py3.7/lib/python3.7/site-packages/wtforms/fields/datetime.py", line 36, in _value return self.data and self.data.strftime(self.format[0]) or "" File "/Users/iuliia_volkova2/Library/Caches/pypoetry/virtualenvs/admin-panel-service-Ji2bEy0B-py3.7/lib/python3.7/site-packages/sqlalchemy/sql/elements.py", line 582, in bool raise TypeError("Boolean value of this clause is not defined") TypeError: Boolean value of this clause is not defined

    Steps to reproduce the bug

    I think something in model cause in issue - I send the sample

    Also we use async SQLAlchemy engine. I will be glad if you will do some input where to dig or what can be a reason of the problem.

    Expected behavior

    Create form open correctly without issues.

    Actual behavior

    Impossible to open Create form

    Debugging material

    No response

    Environment

    SQLAdmin == 0.1.9 SQLAlchemy == 1.4.37

    Additional context

    No response

    opened by xnuinside 15
  • Datetime field can't choose from panel

    Datetime field can't choose from panel

    Checklist

    • [X] The bug is reproducible against the latest release or master.
    • [X] There are no similar issues or pull requests to fix it yet.

    Describe the bug

    I used SQLAdmin in my personal project(That's awesome 🥳), But the datetime field need to enter manually:

    image

    Maybe choose from panel is better:

    image

    Steps to reproduce the bug

    No response

    Expected behavior

    No response

    Actual behavior

    No response

    Debugging material

    No response

    Environment

    os: mac python: 3.9 sqladmin: lastest

    Additional context

    No response

    opened by ischaojie 14
  • Edit functionality not working for Relationship Field (sqlmodel)

    Edit functionality not working for Relationship Field (sqlmodel)

    Checklist

    • [X] The bug is reproducible against the latest release or master.
    • [X] There are no similar issues or pull requests to fix it yet.

    Describe the bug

    When we go on the sql edit admin interface, the Relationship field are not correctly displayed. see the sample code. Only one relation is created between foos and bars. But here is what is displayed

    image

    And when we click on edit

    image

    On the detailed view everything is fine though

    image

    Steps to reproduce the bug

    Sample code

    from sqlmodel import Field
    from sqlmodel import Relationship
    from sqlmodel import SQLModel
    from typing import Optional, List
    from app.db import create_db_and_tables
    from sqlmodel import Session
    from app.db import engine 
    from sqladmin import ModelAdmin
    from app.app import admin
    
    
    class FooTable(SQLModel, table=True):
        """
        FooTable class, in one to many relationship with BarTable
        """
        __tablename__ = 'foo_table'
        id: Optional[int] = Field(default=None, primary_key=True)
        value: float
        bars: List['BarTable'] = Relationship(back_populates='foo')
            
    class BarTable(SQLModel, table=True):
        """
        BarTable class, in many to one relationship with FooTable
        """
        __tablename__ = 'bar_table'
        id: Optional[int] = Field(default=None, primary_key=True)
        foo_id: Optional[int] = Field(default=None, foreign_key='foo_table.id')
        foo: Optional['FooTable'] = Relationship(back_populates='bars')
    create_db_and_tables(BarTable)
    
    
    with Session(engine) as session:
        for i in range(100):
            session.add(FooTable(value=i))
            session.add(BarTable(value=i))
        foo_100 = FooTable(value=100)
        session.add(foo_100)
        session.add(BarTable(value=i, foo=foo_100))
        session.commit()
    
        
    class FooAdmin(ModelAdmin, model=FooTable):
        column_list = [FooTable.id, FooTable.value]
        
    class BarAdmin(ModelAdmin, model=BarTable):
        column_list = [BarTable.id]
        
    
    admin.add_view(FooAdmin)
    admin.add_view(BarAdmin)
    

    Expected behavior

    Either the Relationship field should not be edited, or just the foreign key field should appear in the edit template.

    Actual behavior

    The relationship Fields cannot be edited AND the whole other table is displayed there

    Debugging material

    No response

    Environment

    image

    Python 3.10 (python:3.10-slim base image). Latest sqladmin==0.3.0

    Additional context

    No response

    opened by tepelbaum 12
  • SqlAlchemy InvalidColumnReference error when listing entities that have a lazy=

    SqlAlchemy InvalidColumnReference error when listing entities that have a lazy="subquery" relationship

    Checklist

    • [X] The bug is reproducible against the latest release or master.
    • [X] There are no similar issues or pull requests to fix it yet.

    Describe the bug

    When going on /list the SELECT SQLAlchemy statement fails with the following error : image

    We have an InvalidColumnReference SELECT DISTINCT, ORDER BY expressions must appear in select list

    I'm having this error only on a specific model which has a One to One on another table (lazy="subquery")

    It seems to be order_by should use the column and not the column name

    Steps to reproduce the bug

    I'm having Two models, roughtly

    class PublicationOrm(Base):
        __tablename__ = "publications"
        id = Column(String, primary_key=True)
    
        ...
    
        profile_picture_id = Column(String, ForeignKey("images.id"))
        _cropped_profile_picture = relationship(
            "ImageOrm", lazy="subquery", foreign_keys=[profile_picture_id])
    
    
    class ImageOrm(Base):
        __tablename__ = "images"
    
        id = Column(String, primary_key=True)
        _filename = Column("filename", String)
        x = Column(Integer)
        y = Column(Integer)
        width = Column(Integer)
        height = Column(Integer)
    

    I expect someone having this setup and getting the /list page to have a 500 error (see above)

    Expected behavior

    No error

    Actual behavior

    500 error

    Debugging material

    No response

    Environment

    • Ubuntu 20
    • python 3.9.5
    • sqlalchemy ==1.4.37

    Additional context

    No response

    bug 
    opened by lebrunthibault 10
  • Use zip for iterating over the formatted values

    Use zip for iterating over the formatted values

    Fix to use zip for iterating over the formatted values. It prevents retrieving formatted_value by index especially when it is Iterable but not Sequence.

    Ref. #204.

    opened by okapies 9
  • add the login function

    add the login function

    I tried adding the login function. Including the following:

    1. A User model
    2. A script to create a user
    3. Reads the fields required for user-generated passwords from. Env.
    4. Login html can use i18n and Chinese.

    Now there has some question: 1.I don't know how to create an executable with setup.py.(I can only use poetry to create a program by tool.poetry.scripts) 2. Most of this update is from my old project.But it need deeply test. 3. Doc need update.

    In new version,you need create a .env in project's root.And .env need this data(like this): SECRET_KEY=aawinjwol;egbfnjek bnl DATABASE_URL=sqlite:///example.db

    If you want to create a manager: bash

    sqladmin username password
    
    opened by Chise1 9
  • Cannot edit item

    Cannot edit item

    Checklist

    • [X] The bug is reproducible against the latest release or master.
    • [X] There are no similar issues or pull requests to fix it yet.

    Describe the bug

    I would like to edit in my database, yet when I click on the edit button I get an Internal Server Error with the following server error message

    ...
    api-web-1  |   File "/usr/local/lib/python3.10/site-packages/sqladmin/helpers.py", line 118, in get_primary_key
    api-web-1  |     assert len(pks) == 1, "Multiple Primary Keys not supported."
    api-web-1  | AssertionError: Multiple Primary Keys not supported.
    

    Do you know how to fix it?

    Steps to reproduce the bug

    class User(SQLModel, table=True):
        user_id: str = Field(primary_key=True, nullable=False)
        e_mail: EmailStr
    
    class UserAdmin(ModelView, model=User):
        column_list = [User.user_id]
        column_searchable_list = [User.user_id]
    
    admin = Admin(app, engine)
    
    admin.add_view(UserAdmin)
    

    Expected behavior

    No response

    Actual behavior

    No response

    Debugging material

    No response

    Environment

    • MacOS
    • Python 3.10
    • SQLAdmin 0.6.1

    Additional context

    No response

    opened by junoriosity 8
  • Adds Pre-commit

    Adds Pre-commit

    Adds a setup file for pre-commit. This allows the linters to be ran in local before pushing a pr. To install do the following:

    • Type in pip install pre-commit
    • Inside an individual repo type in pre-commit install
    • After this users will have to fix linting issues before a commit will go through.

    Note: The pre-commit hooks can be skipped by adding -n to a commit

    The following linters were added:

    • autoflake: used in github actions
    • isort: used in github actions
    • black: used in github actions
    • flake8: used in github actions
    • Some basic builtins: check-yaml, end-of-file-fixer, trailing-whitespaces, check-merge-conflict, detect-private-key
    • codespell: makes sure that words in code are spelled correctly
    • pyupgrade: checks for outdated syntax in python
    opened by colin99d 8
  • [WIP] sqlalchemy_utils for ColorType, JSONType, PasswordType, ScalarListType

    [WIP] sqlalchemy_utils for ColorType, JSONType, PasswordType, ScalarListType

    This PR attempts to add the remaining sqlachemy_utils data types. Complete list here: https://sqlalchemy-utils.readthedocs.io/en/latest/data_types.html#module-sqlalchemy_utils.types.choice. Notes for each one appear below:

    • ArrowType: already implemented
    • ChoiceType: got this to work, but implementation is not super user friendly. Would love suggestions for a better implementation
    • CompositeType: postgres specific and I use mysql (:, skipping
    • ColorType: implemented
    • CountryType, CurrencyType, LocalType, WeekDaysType: currently breaks if nothing is sent to the form, this seems to be common among all forms using Babel. @aminalaee do you have any suggestion on how I could fix this?
    • : already implemented
    • EmailType: Did in #150
    • EncryptedType: currently this uses a binary encryption which is not practical to type into a form. Based on their documentation this will be changed to a string implementation in the future and we can implement then.
    • JSONType: implemented
    • LtreeType: postgres specific and I use mysql (:, skipping
    • IPAddressType: Did in #150
    • PasswordType: implemented
    • PhoneNumberType: This uses composite type, how do we want to implement it?
    • ScalarListType: implemented, however adding an item does not work well (I still think a bad implementation is better than the presence of the field crashing the server)
    • TimezoneType: implemented
    • TSVectorType: postgres specific and I use mysql (:, skipping
    • URLType: already implemented
    • UUIDType: already implemented
    opened by colin99d 8
  • Many to many field setup error

    Many to many field setup error

    Checklist

    • [X] The bug is reproducible against the latest release or master.
    • [X] There are no similar issues or pull requests to fix it yet.

    Describe the bug

    I am trying to update m2m field in form but i am getting error "sqlalchemy.exc.InvalidRequestError: Can't attach instance another instance with key is already present in this session"

    Steps to reproduce the bug

    No response

    Expected behavior

    No response

    Actual behavior

    No response

    Debugging material

    No response

    Environment

    Macos , python 3.9

    Additional context

    No response

    opened by dasaderto 8
  • fix docstring issues by adding an explicit handler

    fix docstring issues by adding an explicit handler

    Long story short: fixes #104.

    Locking the dependency uses mkdocstrings's so-called "experimental" handler for docstring parsing. The new one properly parses the docstring in this case whereas the legacy one does not.

    opened by dwreeves 8
  • Convertor for PhoneNumberType

    Convertor for PhoneNumberType

    Checklist

    • [X] The bug is reproducible against the latest release or master.
    • [X] There are no similar issues or pull requests to fix it yet.

    Describe the bug

    If field of model has PhoneNumberType from sqlalchemy_utils, you cannot create or edit new records.

    Steps to reproduce the bug

    1. Made model with
    2. Add to admin panel.
    3. Try to create new one or update old one.

    Expected behavior

    Can edit and create new records.

    Actual behavior

    Getting Internal Error.

    Debugging material

    Traceback (most recent call last):
      File "/home/aryadovoy/Documents/coding/back/.venv/lib/python3.11/site-packages/uvicorn/protocols/http/httptools_impl.py", line 419, in run_asgi
        result = await app(  # type: ignore[func-returns-value]
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/aryadovoy/Documents/coding/back/.venv/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 78, in __call__
        return await self.app(scope, receive, send)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/aryadovoy/Documents/coding/back/.venv/lib/python3.11/site-packages/fastapi/applications.py", line 270, in __call__
        await super().__call__(scope, receive, send)
      File "/home/aryadovoy/Documents/coding/back/.venv/lib/python3.11/site-packages/starlette/applications.py", line 124, in __call__
        await self.middleware_stack(scope, receive, send)
      File "/home/aryadovoy/Documents/coding/back/.venv/lib/python3.11/site-packages/starlette/middleware/errors.py", line 184, in __call__
        raise exc
      File "/home/aryadovoy/Documents/coding/back/.venv/lib/python3.11/site-packages/starlette/middleware/errors.py", line 162, in __call__
        await self.app(scope, receive, _send)
      File "/home/aryadovoy/Documents/coding/back/.venv/lib/python3.11/site-packages/starlette/middleware/cors.py", line 84, in __call__
        await self.app(scope, receive, send)
      File "/home/aryadovoy/Documents/coding/back/.venv/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 79, in __call__
        raise exc
      File "/home/aryadovoy/Documents/coding/back/.venv/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 68, in __call__
        await self.app(scope, receive, sender)
      File "/home/aryadovoy/Documents/coding/back/.venv/lib/python3.11/site-packages/fastapi/middleware/asyncexitstack.py", line 21, in __call__
        raise e
      File "/home/aryadovoy/Documents/coding/back/.venv/lib/python3.11/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__
        await self.app(scope, receive, send)
      File "/home/aryadovoy/Documents/coding/back/.venv/lib/python3.11/site-packages/starlette/routing.py", line 706, in __call__
        await route.handle(scope, receive, send)
      File "/home/aryadovoy/Documents/coding/back/.venv/lib/python3.11/site-packages/starlette/routing.py", line 443, in handle
        await self.app(scope, receive, send)
      File "/home/aryadovoy/Documents/coding/back/.venv/lib/python3.11/site-packages/starlette/applications.py", line 124, in __call__
        await self.middleware_stack(scope, receive, send)
      File "/home/aryadovoy/Documents/coding/back/.venv/lib/python3.11/site-packages/starlette/middleware/errors.py", line 184, in __call__
        raise exc
      File "/home/aryadovoy/Documents/coding/back/.venv/lib/python3.11/site-packages/starlette/middleware/errors.py", line 162, in __call__
        await self.app(scope, receive, _send)
      File "/home/aryadovoy/Documents/coding/back/.venv/lib/python3.11/site-packages/starlette/middleware/sessions.py", line 86, in __call__
        await self.app(scope, receive, send_wrapper)
      File "/home/aryadovoy/Documents/coding/back/.venv/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 79, in __call__
        raise exc
      File "/home/aryadovoy/Documents/coding/back/.venv/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 68, in __call__
        await self.app(scope, receive, sender)
      File "/home/aryadovoy/Documents/coding/back/.venv/lib/python3.11/site-packages/starlette/routing.py", line 706, in __call__
        await route.handle(scope, receive, send)
      File "/home/aryadovoy/Documents/coding/back/.venv/lib/python3.11/site-packages/starlette/routing.py", line 276, in handle
        await self.app(scope, receive, send)
      File "/home/aryadovoy/Documents/coding/back/.venv/lib/python3.11/site-packages/starlette/routing.py", line 66, in app
        response = await func(request)
                   ^^^^^^^^^^^^^^^^^^^
      File "/home/aryadovoy/Documents/coding/back/.venv/lib/python3.11/site-packages/sqladmin/authentication.py", line 56, in wrapper_decorator
        return await func(*args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/aryadovoy/Documents/coding/back/.venv/lib/python3.11/site-packages/sqladmin/application.py", line 465, in edit
        Form = await model_view.scaffold_form()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/aryadovoy/Documents/coding/back/.venv/lib/python3.11/site-packages/sqladmin/models.py", line 1005, in scaffold_form
        return await get_model_form(
               ^^^^^^^^^^^^^^^^^^^^^
      File "/home/aryadovoy/Documents/coding/back/.venv/lib/python3.11/site-packages/sqladmin/forms.py", line 536, in get_model_form
        field = await converter.convert(
                ^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/aryadovoy/Documents/coding/back/.venv/lib/python3.11/site-packages/sqladmin/forms.py", line 302, in convert
        converter = self.get_converter(prop=prop)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/aryadovoy/Documents/coding/back/.venv/lib/python3.11/site-packages/sqladmin/forms.py", line 255, in get_converter
        raise NoConverterFound(  # pragma: nocover
    sqladmin.exceptions.NoConverterFound: Could not find field converter for column phone_number (<class 'sqlalchemy_utils.types.phone_number.PhoneNumberType'>).
    

    Environment

    OS: Fedora Linux 35 (KDE Plasma) x86_64 Python: 3.11.0 SQLAdmin: 0.8.0

    Additional context

    No response

    opened by aryadovoy 4
  • add inline models

    add inline models

    Checklist

    • [X] There are no similar issues or pull requests for this yet.

    Is your feature related to a problem? Please describe.

    I want to be able to add inline model like in flask-admin. I think it's very helpful feature

    Screenshot_20221215_044051

    Screenshot_20221215_044123

    Describe the solution you would like.

    No response

    Describe alternatives you considered

    No response

    Additional context

    No response

    opened by 0nliner 0
  • Allow different views for same model

    Allow different views for same model

    Checklist

    • [X] There are no similar issues or pull requests for this yet.

    Is your feature related to a problem? Please describe.

    Identity is not overwritten in metaclass even if in attrs cls.identity = slugify_class_name(model.__name__)

    Describe the solution you would like.

    It should be possible to create something like cls.identity = attrs.get("identity", slugify_class_name(model.__name__)

    Although edit links will need to be updated accordingly, of course.

    Describe alternatives you considered

    No response

    Additional context

    No response

    opened by jsmolina 4
  • Handling of `lazy=

    Handling of `lazy="dynamic"` relationships

    Checklist

    • [X] The bug is reproducible against the latest release or master.
    • [X] There are no similar issues or pull requests to fix it yet.

    Describe the bug

    Model relations are automatically loaded regardless of the ModelView configuration, this causes issues with relationships defined as lazy="dynamic" because it ends up in InvalidRequestError( '%s' does not support object population - eager loading cannot be applied.) from sqlalchemy. The error is raised on any list or detail request.

    The current workaround I'm applying is:

    
    class ModelView(ModelView):
        def __init__(self) -> None:
            super().__init__()
            self._relations = [rel for rel in self._relations if rel.lazy != "dynamic"]
    

    Steps to reproduce the bug

    Setting up two SQLAlchemy Models and configuring a relationship between them with the lazy="dynamic" parameter should suffice

    Expected behavior

    1. Relationships not being listed as part of column_list or column_details_list are not eagerly loaded
    2. Relationships with lazy="dynamic" are either ignored (short term fix?) or correctly handled (longer term feature?)

    Actual behavior

    InvalidRequestError causes the ModelView to be unusable for models with lazy="dynamic" relationships

    Debugging material

    Starlette Debugger.pdf

    Environment

    • OS: Debian 11 (Bullseye)
    • Python: 3.11
    • SQLAlchemy: 1.4.44

    Additional context

    No response

    opened by jarojasm95 4
  • Starlite integration

    Starlite integration

    Checklist

    • [X] There are no similar issues or pull requests for this yet.

    Is your feature related to a problem? Please describe.

    I'd like to be able to use this with the Starlite framework.

    Describe the solution you would like.

    Starlite recently removed the Starlette dependency, limiting the ability to use this tool on that framework. I would like to contribute to a solution that works with Starlite.

    I'm looking for guidance on how best to integrate this functionality. (i.e. separate fork, PR to integrate into main)

    Describe alternatives you considered

    No response

    Additional context

    No response

    opened by cofin 1
  • When trying to add a filefield, a string value comes in instead of a file

    When trying to add a filefield, a string value comes in instead of a file

    Checklist

    • [X] The bug is reproducible against the latest release or master.
    • [X] There are no similar issues or pull requests to fix it yet.

    Describe the bug

    I want to add a file download. But if I add a file widget, it comes with a string instead of a file. How can this be fixed?

    class IconAdmin(ModelView, model=Icon):
        form_columns = [Icon.name, Icon.file]
        form_overrides = dict(file=FileField)
    

    The file field in the icon model has a string type. Could this be the problem? And if so, what needs to be fixed?

    Steps to reproduce the bug

    No response

    Expected behavior

    No response

    Actual behavior

    No response

    Debugging material

    No response

    Environment

    python 3.9.13 sqladmin 0.4.0 sqlmodel 0.0.6

    Additional context

    No response

    opened by timuralchin 7
Releases(0.8.0)
  • 0.8.0(Nov 22, 2022)

    Added

    • Add save_as option by @aminalaee in https://github.com/aminalaee/sqladmin/pull/377
    • Add save_as_continue option by @aminalaee in https://github.com/aminalaee/sqladmin/pull/379
    • Add extra Save buttons for Create/Edit page by @aminalaee in https://github.com/aminalaee/sqladmin/pull/373
    • Display errors in alert for create/edit page by @aminalaee in https://github.com/aminalaee/sqladmin/pull/382

    Fixed

    • Fix _url_for methods ignoring root_path by @aminalaee in https://github.com/aminalaee/sqladmin/pull/371
    • Fix export to use list_query option by @villqrd in https://github.com/aminalaee/sqladmin/pull/381

    New Contributors

    • @villqrd made their first contribution in https://github.com/aminalaee/sqladmin/pull/381

    Full Changelog: https://github.com/aminalaee/sqladmin/compare/0.7.0...0.8.0

    Source code(tar.gz)
    Source code(zip)
  • 0.7.0(Nov 3, 2022)

    Added

    • Add on_model_change and after_model_change methods by @dima23113 in https://github.com/aminalaee/sqladmin/pull/342
    • Add on_model_delete and after_model_delete methods by @aminalaee in https://github.com/aminalaee/sqladmin/pull/343

    Fixed

    • Fix search by uuid column by @aminalaee in https://github.com/aminalaee/sqladmin/pull/366
    • Update tests after starlette upgrade by @aminalaee in https://github.com/aminalaee/sqladmin/pull/344
    • Remove hard-coded related model limit by @aminalaee in https://github.com/aminalaee/sqladmin/pull/354
    • Improve items list UI by @ischaojie in https://github.com/aminalaee/sqladmin/pull/349
    • Make navbar work on small screens by @aminalaee in https://github.com/aminalaee/sqladmin/pull/362

    Internal

    • Add mypy check with config no_implicit_optional by @ischaojie in https://github.com/aminalaee/sqladmin/pull/360
    • Support test-suite py311 by @ischaojie in https://github.com/aminalaee/sqladmin/pull/365
    • Add py.typed for the package to ship its typing information by @franciscorode in https://github.com/aminalaee/sqladmin/pull/346

    Full Changelog: https://github.com/aminalaee/sqladmin/compare/0.6.1...0.7.0

    Source code(tar.gz)
    Source code(zip)
  • 0.6.1(Sep 25, 2022)

    Fixed

    • Fix Boolean field for both nullable and non-nullable cases in https://github.com/aminalaee/sqladmin/pull/336
    • Fix Flatpickr not respecting readonly inputs in https://github.com/aminalaee/sqladmin/pull/336
    • Disable batch delete when can_delete permission is not provided in https://github.com/aminalaee/sqladmin/pull/335

    Full Changelog: https://github.com/aminalaee/sqladmin/compare/0.6.0...0.6.1

    Source code(tar.gz)
    Source code(zip)
  • 0.6.0(Sep 19, 2022)

    Added

    • Add bulk delete action by @aminalaee in https://github.com/aminalaee/sqladmin/pull/317

    Fixed

    • Handle null values when column is nullable by @aminalaee in https://github.com/aminalaee/sqladmin/pull/323
    • Switch Boolean field to select field by @aminalaee in https://github.com/aminalaee/sqladmin/pull/321

    Internal

    • Fix form_ajax_refs example in documentation by @GitBib in https://github.com/aminalaee/sqladmin/pull/311
    • Remove watch in mkdocstrings mkdocs's config by @ischaojie in https://github.com/aminalaee/sqladmin/pull/306

    Full Changelog: https://github.com/aminalaee/sqladmin/compare/0.5.0...0.6.0

    Source code(tar.gz)
    Source code(zip)
  • 0.5.0(Sep 6, 2022)

    Added

    • Add remote_ajax_refs by @aminalaee in https://github.com/aminalaee/sqladmin/pull/292

    Fixed

    • Fix sorting with column_labels by @GitBib in https://github.com/aminalaee/sqladmin/pull/305

    Internal

    • Avoid select query with ajax_form_refs by @aminalaee in https://github.com/aminalaee/sqladmin/pull/300

    New Contributors

    • @GitBib made their first contribution in https://github.com/aminalaee/sqladmin/pull/305

    Full Changelog: https://github.com/aminalaee/sqladmin/compare/0.4.0...0.5.0

    Source code(tar.gz)
    Source code(zip)
  • 0.4.0(Aug 31, 2022)

    Added

    • Add Date and DateTime pickers using Fatpickr in https://github.com/aminalaee/sqladmin/pull/288
    • Add Time picker using Flatpickr in https://github.com/aminalaee/sqladmin/pull/294

    Internal

    • Remove MomentJS in https://github.com/aminalaee/sqladmin/pull/289

    Full Changelog: https://github.com/aminalaee/sqladmin/compare/0.3.0...0.4.0

    Source code(tar.gz)
    Source code(zip)
  • 0.3.0(Aug 26, 2022)

    Added

    • Add AuthenticationBackend in https://github.com/aminalaee/sqladmin/pull/277
    • Add AuthenticationBackend docs in https://github.com/aminalaee/sqladmin/pull/278

    Full Changelog: https://github.com/aminalaee/sqladmin/compare/0.2.1...0.3.0

    Source code(tar.gz)
    Source code(zip)
  • 0.2.1(Aug 4, 2022)

    Fixed

    • Fix middlewares and ENGINE_TYPE types by @jockerz in https://github.com/aminalaee/sqladmin/pull/266
    • Fix middlewares not being applied by @aminalaee in https://github.com/aminalaee/sqladmin/pull/267 and https://github.com/aminalaee/sqladmin/pull/271

    New Contributors

    • @jockerz made their first contribution in https://github.com/aminalaee/sqladmin/pull/266

    Full Changelog: https://github.com/aminalaee/sqladmin/compare/0.2.0...0.2.1

    Source code(tar.gz)
    Source code(zip)
  • 0.2.0(Aug 1, 2022)

    Added

    • Add list_query, count_query and search_query options by @aminalaee in https://github.com/aminalaee/sqladmin/pull/243
    • Add BaseView for custom pages by @just-an-dev in https://github.com/aminalaee/sqladmin/pull/244
    • Add expose for BaseView in https://github.com/aminalaee/sqladmin/pull/251
    • Rename ModelAdmin to ModelView in https://github.com/aminalaee/sqladmin/pull/249

    New Contributors

    • @just-an-dev made their first contribution in https://github.com/aminalaee/sqladmin/pull/244

    Full Changelog: https://github.com/aminalaee/sqladmin/compare/0.1.12...0.2.0

    Source code(tar.gz)
    Source code(zip)
  • 0.1.12(Jul 13, 2022)

    Added

    • Add time field converter by @ischaojie in https://github.com/aminalaee/sqladmin/pull/214
    • Add Edit button for "Details" page by @cuamckuu in https://github.com/aminalaee/sqladmin/pull/222
    • Add column_type_formatters by @aminalaee in https://github.com/aminalaee/sqladmin/pull/239

    Fixed

    • Fix lazy subuqery in list query by @aminalaee in https://github.com/aminalaee/sqladmin/pull/212
    • Fix missing browser tab title by @cuamckuu in https://github.com/aminalaee/sqladmin/pull/229
    • Remove sourceMappingURL in JS files by @aminalaee in https://github.com/aminalaee/sqladmin/pull/231

    New Contributors

    • @ischaojie made their first contribution in https://github.com/aminalaee/sqladmin/pull/214
    • @cuamckuu made their first contribution in https://github.com/aminalaee/sqladmin/pull/222

    Full Changelog: https://github.com/aminalaee/sqladmin/compare/0.1.11...0.1.12

    Source code(tar.gz)
    Source code(zip)
  • 0.1.11(Jun 23, 2022)

    Added

    • Add form_include_pk option by @aminalaee in https://github.com/aminalaee/sqladmin/pull/207

    Fixed

    • Fix handling of iterable fields by @okapies in https://github.com/aminalaee/sqladmin/pull/204
    • Fix nullable Enum form by @aminalaee in https://github.com/aminalaee/sqladmin/pull/205

    Full Changelog: https://github.com/aminalaee/sqladmin/compare/0.1.10...0.1.11

    Source code(tar.gz)
    Source code(zip)
  • 0.1.10(Jun 21, 2022)

    Added

    • Add support for one-to-one relationship by @okapies in https://github.com/aminalaee/sqladmin/pull/182
    • Add support for UUIDType from sqlalchemy_utils by @okapies in https://github.com/aminalaee/sqladmin/pull/183
    • Add sqlalchemy_utils URL, Currency and Timezone by @aminalaee in https://github.com/aminalaee/sqladmin/pull/185
    • Add form_widget_args by @aminalaee in https://github.com/aminalaee/sqladmin/pull/188
    • Add column_default_sort by @aminalaee in https://github.com/aminalaee/sqladmin/pull/191

    Fixed

    • Fix link relationship to details page when null by @aminalaee in https://github.com/aminalaee/sqladmin/pull/174
    • docs: fix typos by @pgrimaud in https://github.com/aminalaee/sqladmin/pull/161
    • Allow QuerySelectField override object_list with form_args by @aminalaee in https://github.com/aminalaee/sqladmin/pull/171
    • Fix form fields order when specifying columns by @okapies in https://github.com/aminalaee/sqladmin/pull/184
    • Fix ModelConverter when impl is not callable by @aminalaee in https://github.com/aminalaee/sqladmin/pull/186

    New Contributors

    • @pgrimaud made their first contribution in https://github.com/aminalaee/sqladmin/pull/161
    • @okapies made their first contribution in https://github.com/aminalaee/sqladmin/pull/183

    Full Changelog: https://github.com/aminalaee/sqladmin/compare/0.1.9...0.1.10

    Source code(tar.gz)
    Source code(zip)
  • 0.1.9(May 29, 2022)

    Version 0.1.9 - 2022-05-27

    Added

    • Add column_formatters by @skarrok in https://github.com/aminalaee/sqladmin/pull/140
    • Add column_formatters_detail by @aminalaee in https://github.com/aminalaee/sqladmin/pull/141
    • Handling for sqlalchemy_utils EmailType and IPAddressType by @colin99d in https://github.com/aminalaee/sqladmin/pull/150
    • Link relationships to detail page by @aminalaee in https://github.com/aminalaee/sqladmin/pull/153

    Fixed

    • Function signature typing, and renames by @dwreeves in https://github.com/aminalaee/sqladmin/pull/116
    • Fix SQLModel UUID type by @aminalaee in https://github.com/aminalaee/sqladmin/pull/158

    New Contributors

    • @skarrok made their first contribution in https://github.com/aminalaee/sqladmin/pull/140
    • @colin99d made their first contribution in https://github.com/aminalaee/sqladmin/pull/150

    Full Changelog: https://github.com/aminalaee/sqladmin/compare/0.1.8...0.1.9

    Source code(tar.gz)
    Source code(zip)
  • 0.1.8(Apr 19, 2022)

    Version 0.1.8 - 2022-04-18

    Added

    • Add csv export support by @dwreeves in https://github.com/aminalaee/sqladmin/pull/101
    • Expose Starlette middlewares and debug to the Admin by @tr11 in https://github.com/aminalaee/sqladmin/pull/114

    Fixed

    • Fix Export unlimited rows by @aminalaee in https://github.com/aminalaee/sqladmin/pull/107
    • Add form and export options docs by @aminalaee in https://github.com/aminalaee/sqladmin/pull/110
    • fix docstring issues by adding an explicit handler by @dwreeves in https://github.com/aminalaee/sqladmin/pull/106
    • Fix get_model_attr with column labels by @aminalaee in https://github.com/aminalaee/sqladmin/pull/128
    • Delay call to self.get_converter by @lovetoburnswhen in https://github.com/aminalaee/sqladmin/pull/129

    New Contributors

    • @tr11 made their first contribution in https://github.com/aminalaee/sqladmin/pull/114
    • @lovetoburnswhen made their first contribution in https://github.com/aminalaee/sqladmin/pull/129

    Full Changelog: https://github.com/aminalaee/sqladmin/compare/0.1.7...0.1.8

    Source code(tar.gz)
    Source code(zip)
  • 0.1.7(Mar 22, 2022)

    Version 0.1.7 - 2022-03-22

    Added

    • Add SQLModel support by @aminalaee in https://github.com/aminalaee/sqladmin/pull/94
    • Add form-specific functionality to ModelAdmin by @dwreeves in https://github.com/aminalaee/sqladmin/pull/97
    • Add UUID field converter by @aminalaee in https://github.com/aminalaee/sqladmin/pull/82
    • Add PostgreSQL INET and MACADDR converters by @aminalaee in https://github.com/aminalaee/sqladmin/pull/83

    Fixed

    • Fix Boolean field checkbox UI by @aminalaee in https://github.com/aminalaee/sqladmin/pull/88
    • Fix PostgreSQL UUID PrimaryKey by @aminalaee in https://github.com/aminalaee/sqladmin/pull/92
    • Fix Source Code Link by @baurt in https://github.com/aminalaee/sqladmin/pull/95

    New Contributors

    • @baurt made their first contribution in https://github.com/aminalaee/sqladmin/pull/95
    • @dwreeves made their first contribution in https://github.com/aminalaee/sqladmin/pull/97

    Full Changelog: https://github.com/aminalaee/sqladmin/compare/0.1.6...0.1.7

    Source code(tar.gz)
    Source code(zip)
  • 0.1.6(Mar 9, 2022)

    Version 0.1.6 - 2022-03-09

    Added

    • FontAwesome6 icons by @EssaAlshammri in https://github.com/aminalaee/sqladmin/pull/78
    • Add column_sortable_list by @aminalaee in https://github.com/aminalaee/sqladmin/pull/65
    • Add JSON column converters by @aminalaee in https://github.com/aminalaee/sqladmin/pull/74

    Fixed

    • Fix URL search regex by @art1415926535 in https://github.com/aminalaee/sqladmin/pull/67
    • Fix Enum in Edit page by @aminalaee in https://github.com/aminalaee/sqladmin/pull/71

    New Contributors

    • @art1415926535 made their first contribution in https://github.com/aminalaee/sqladmin/pull/67
    • @EssaAlshammri made their first contribution in https://github.com/aminalaee/sqladmin/pull/78

    Full Changelog: https://github.com/aminalaee/sqladmin/compare/0.1.5...0.1.6

    Source code(tar.gz)
    Source code(zip)
  • 0.1.5(Feb 24, 2022)

    Version 0.1.5 - 2022-02-24

    Added

    • Authentication in #37
    • Add Edit view page in #60
    • Add column_searchable_list in #61

    Internal

    • Cleanup DB queries in #51

    Full Changelog: https://github.com/aminalaee/sqladmin/compare/0.1.4...0.1.5

    Source code(tar.gz)
    Source code(zip)
  • 0.1.4(Feb 16, 2022)

    Version 0.1.4 - 2022-02-16

    Added

    • Allow templates to be configured in #52
    • Add page size option links in #34

    Fixed

    • Improve pagination in #36

    Internal

    • Instantiate ModelAdmin internally to avoid class methods in #31

    Full Changelog: https://github.com/aminalaee/sqladmin/compare/0.1.3...0.1.4

    Source code(tar.gz)
    Source code(zip)
  • 0.1.3(Jan 24, 2022)

    Version 0.1.3 - 2022-01-24

    Added

    • Add title and logo options by @aminalaee in https://github.com/aminalaee/sqladmin/pull/20
    • Adding order_by to list pagination query by @bigg01 in https://github.com/aminalaee/sqladmin/pull/25
    • Allow Relationship properties in list and detail views by @aminalaee in https://github.com/aminalaee/sqladmin/pull/22

    New Contributors

    • @bigg01 made their first contribution in https://github.com/aminalaee/sqladmin/pull/25

    Full Changelog: https://github.com/aminalaee/sqladmin/compare/0.1.2...0.1.3

    Source code(tar.gz)
    Source code(zip)
fastapi-admin2 is an upgraded fastapi-admin, that supports ORM dialects, true Dependency Injection and extendability

FastAPI2 Admin Introduction fastapi-admin2 is an upgraded fastapi-admin, that supports ORM dialects, true Dependency Injection and extendability. Now

Glib 14 Dec 5, 2022
Prometheus exporter for Starlette and FastAPI

starlette_exporter Prometheus exporter for Starlette and FastAPI. The middleware collects basic metrics: Counter: starlette_requests_total Histogram:

Steve Hillier 225 Jan 5, 2023
A rate limiter for Starlette and FastAPI

SlowApi A rate limiting library for Starlette and FastAPI adapted from flask-limiter. Note: this is alpha quality code still, the API may change, and

Laurent Savaete 562 Jan 1, 2023
Opentracing support for Starlette and FastApi

Starlette-OpenTracing OpenTracing support for Starlette and FastApi. Inspired by: Flask-OpenTracing OpenTracing implementations exist for major distri

Rene Dohmen 63 Dec 30, 2022
A rate limiter for Starlette and FastAPI

SlowApi A rate limiting library for Starlette and FastAPI adapted from flask-limiter. Note: this is alpha quality code still, the API may change, and

Laurent Savaete 154 Feb 16, 2021
Prometheus exporter for Starlette and FastAPI

starlette_exporter Prometheus exporter for Starlette and FastAPI. The middleware collects basic metrics: Counter: starlette_requests_total Histogram:

Steve Hillier 82 Feb 13, 2021
Opentracing support for Starlette and FastApi

Starlette-OpenTracing OpenTracing support for Starlette and FastApi. Inspired by: Flask-OpenTracing OpenTracing implementations exist for major distri

Rene Dohmen 26 Feb 11, 2021
Adds simple SQLAlchemy support to FastAPI

FastAPI-SQLAlchemy FastAPI-SQLAlchemy provides a simple integration between FastAPI and SQLAlchemy in your application. It gives access to useful help

Michael Freeborn 465 Jan 7, 2023
🚀 Cookiecutter Template for FastAPI + React Projects. Using PostgreSQL, SQLAlchemy, and Docker

FastAPI + React · A cookiecutter template for bootstrapping a FastAPI and React project using a modern stack. Features FastAPI (Python 3.8) JWT authen

Gabriel Abud 1.4k Jan 2, 2023
🚀 Cookiecutter Template for FastAPI + React Projects. Using PostgreSQL, SQLAlchemy, and Docker

FastAPI + React · A cookiecutter template for bootstrapping a FastAPI and React project using a modern stack. Features FastAPI (Python 3.8) JWT authen

Gabriel Abud 448 Feb 19, 2021
Sample FastAPI project that uses async SQLAlchemy, SQLModel, Postgres, Alembic, and Docker.

FastAPI + SQLModel + Alembic Sample FastAPI project that uses async SQLAlchemy, SQLModel, Postgres, Alembic, and Docker. Want to learn how to build th

null 228 Jan 2, 2023
Starlette middleware for Prerender

Prerender Python Starlette Starlette middleware for Prerender Documentation: https://BeeMyDesk.github.io/prerender-python-starlette/ Source Code: http

BeeMyDesk 14 May 2, 2021
Middleware for Starlette that allows you to store and access the context data of a request. Can be used with logging so logs automatically use request headers such as x-request-id or x-correlation-id.

starlette context Middleware for Starlette that allows you to store and access the context data of a request. Can be used with logging so logs automat

Tomasz Wójcik 300 Dec 26, 2022
Prometheus integration for Starlette.

Starlette Prometheus Introduction Prometheus integration for Starlette. Requirements Python 3.6+ Starlette 0.9+ Installation $ pip install starlette-p

José Antonio Perdiguero 229 Dec 21, 2022
Starlette middleware for Prerender

Prerender Python Starlette Starlette middleware for Prerender Documentation: https://BeeMyDesk.github.io/prerender-python-starlette/ Source Code: http

BeeMyDesk 13 Jul 27, 2020
Middleware for Starlette that allows you to store and access the context data of a request. Can be used with logging so logs automatically use request headers such as x-request-id or x-correlation-id.

starlette context Middleware for Starlette that allows you to store and access the context data of a request. Can be used with logging so logs automat

Tomasz Wójcik 110 Feb 16, 2021
Prometheus integration for Starlette.

Starlette Prometheus Introduction Prometheus integration for Starlette. Requirements Python 3.6+ Starlette 0.9+ Installation $ pip install starlette-p

José Antonio Perdiguero 125 Feb 13, 2021
Dead simple CSRF security middleware for Starlette ⭐ and Fast API ⚡

csrf-starlette-fastapi Dead simple CSRF security middleware for Starlette ⭐ and Fast API ⚡ Will work with either a <input type="hidden"> field or ajax

Nathaniel Sabanski 9 Nov 20, 2022
:rocket: CLI tool for FastAPI. Generating new FastAPI projects & boilerplates made easy.

Project generator and manager for FastAPI. Source Code: View it on Github Features ?? Creates customizable project boilerplate. Creates customizable a

Yagiz Degirmenci 1k Jan 2, 2023