-
Notifications
You must be signed in to change notification settings - Fork 30
Open
Description
Hi!, After setting up FastAdmin for my Flask and SQLAlchemy application, I found that the basic operations (listing, creating, deleting) are working as expected. However, I've encountered an issue when trying to edit an entity. The edit screen appears blank. Interestingly, the API calls (like /admin/api/retrieve/User/ebae54de-f1eb-4d47-b620-e2ac2c9cf500) seem to be correct, returning a 200 status code along with the model data
See attachments:
This is the code:
from src.contexts.venuescast.user.infrastructure.orm import User
sqlalchemy_engine = create_async_engine(
config.ASYNC_SQLALCHEMY_DATABASE_URI,
echo=True,
poolclass=NullPool
)
sqlalchemy_sessionmaker = async_sessionmaker(sqlalchemy_engine, expire_on_commit=False)
@register(User, sqlalchemy_sessionmaker=sqlalchemy_sessionmaker)
class UserAdmin(SqlAlchemyModelAdmin):
exclude = ("hash_password",)
list_display = ("id", "username", "is_superuser", "is_active")
list_display_links = ("id", "username")
list_filter = ("id", "username", "is_superuser", "is_active")
search_fields = ("username",)
form_fields = ("username", "is_superuser", "is_active") #
async def authenticate(self, username: str, password: str) -> uuid.UUID | int | None:
sessionmaker = self.get_sessionmaker()
async with sessionmaker() as session:
query = select(self.model_cls).filter_by(username=username)
result = await session.scalars(query)
obj = result.first()
if not obj:
return None
return obj.id
app.register_blueprint(admin_app, url_prefix="/admin", static_url_path="/admin/static",)
Additional info:
- I can see UI for a ms but goes blank straight away.
- It has been tested on BRAVE and Safari browsers
Thank you!
Metadata
Metadata
Assignees
Labels
No labels

