Reputation: 23
I am trying to use flask-admin in fast api. I created two apps (fastapi and flask) but i do not know what do next.
flask_app = Flask(__name__)
fastapi_app = FastAPI()
fastapi_app.mount("/static", StaticFiles(directory="static"), name="static")
templates = Jinja2Templates(directory="templates")
engine = create_engine('##################################')
db = Session(engine)
admin = Admin(flask_app, template_mode='bootstrap4')
admin.add_view(ModelView(Users, db))
admin.add_view(ModelView(Rooms, db))
admin.add_view(ModelView(UsersToRooms, db))
admin.add_view(ModelView(Maps, db))
fastapi_app.mount("/admin", admin)
I get this error
TypeError: 'Admin' object is not callable
How can i do it?
Upvotes: 0
Views: 1080
Reputation: 1
I had the same problem and in case someone needs an answer, the following worked for me:
When mounting the app with fast_api.app.mount, not the Admin class instance but the app attribute of that instance has to be passed to mount()
For the above example:
fastapi_app.mount("/admin", admin.app)
instead of
fastapi_app.mount("/admin", admin)
Upvotes: 0