-
Notifications
You must be signed in to change notification settings - Fork 269
Closed
Description
Checklist
- The bug is reproducible against the latest release or
master. - There are no similar issues or pull requests to fix it yet.
Describe the bug
Hy there,
I am using fastapi_users for authentication .
Here is the code,
inside app directory
app.py
from contextlib import asynccontextmanager
from fastapi import FastAPI
from sqladmin import Admin, ModelView
from app.db import User, create_db_and_tables, engine
@asynccontextmanager
async def lifespan(app: FastAPI):
await create_db_and_tables()
yield
app = FastAPI(lifespan=lifespan)
admin = Admin(app, engine)
class UserAdmin(ModelView, model=User):
...
admin.add_view(UserAdmin)
in db.py
from typing import AsyncGenerator
from fastapi import Depends
from fastapi_users.db import SQLAlchemyBaseUserTableUUID, SQLAlchemyUserDatabase
from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker, create_async_engine
from sqlalchemy.orm import DeclarativeBase
DATABASE_URL = "sqlite+aiosqlite:///./test.db"
class Base(DeclarativeBase):
pass
class User(SQLAlchemyBaseUserTableUUID, Base):
pass
engine = create_async_engine(DATABASE_URL)
async_session_maker = async_sessionmaker(engine, expire_on_commit=False)
async def create_db_and_tables():
async with engine.begin() as conn:
await conn.run_sync(Base.metadata.create_all)
async def get_async_session() -> AsyncGenerator[AsyncSession, None]:
async with async_session_maker() as session:
yield session
async def get_user_db(session: AsyncSession = Depends(get_async_session)):
yield SQLAlchemyUserDatabase(session, User)
in main.py
import uvicorn
if __name__ == "__main__":
uvicorn.run("app.app:app", host="0.0.0.0", log_level="info", port=8000, reload=True)
directory structure
project
-app
- app.py
- db.py
-main.py
python main.py to run program
requirements.txt
fastapi
fastapi-users[sqlalchemy]
uvicorn[standard]
aiosqlite
sqladmin
this line generate issue
Line 229 in cdff6b4
| value = False if type_ is bool and part == "False" else type_(part) |
Steps to reproduce the bug
This issue arise when I visit details and edit section , just for example
http://127.0.0.1:8000/admin/user/details/0ab165e9-7408-45ef-8179-c2d5f18f44fb
http://127.0.0.1:8000/admin/user/edit/0ab165e9-7408-45ef-8179-c2d5f18f44fb
Expected behavior
No response
Actual behavior
No response
Debugging material
No response
Environment
- window 11 , python 3.11
Additional context
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels