Describe the bug
CustomViews do not load when added to admin instance after mounting
To Reproduce
Create an Admin instance, add the custom view, then mount the Admin to an app. This will render fine.
However, the following will not render the custom view:
- Create admin instance
- Mount admin to app
- Add custom view
The first scenario will render the specified templates just fine, while the 2nd returns 404. This is confusing because ModelViews are not affected in the same way
Environment (please complete the following information):
- Starlette-Admin version: ">=0.15.1"
- ORM/ODMs: SQLAlchemy
Additional context
App being mounted is a FastAPI instance
# This works as expected and the custom view is accessible at the path
def register_admin(app: FastAPI) -> FastAPI:
admin = Admin(
...,
templates_dir="templates/admin/",
index_view=admin_home.HomeView(label="Home", icon="fa fa-home"),
)
# Custom Views
admin.add_view(
embeds.DashboardsView(
label="Dashboards",
icon="fa fa-gauge",
path="/dashboards",
template_path="dashboards.html",
add_to_menu=True,
)
)
admin.mount_to(app)
return app
# This returns a 404 when accessing the customView path
def register_admin(app: FastAPI) -> FastAPI:
admin = Admin(
...,
templates_dir="templates/admin/",
index_view=admin_home.HomeView(label="Home", icon="fa fa-home"),
)
admin.mount_to(app)
# Custom Views
admin.add_view(
embeds.DashboardsView(
label="Dashboards",
icon="fa fa-gauge",
path="/dashboards",
template_path="dashboards.html",
add_to_menu=True,
)
)
return app
Describe the bug
CustomViews do not load when added to admin instance after mounting
To Reproduce
Create an Admin instance, add the custom view, then mount the Admin to an app. This will render fine.
However, the following will not render the custom view:
The first scenario will render the specified templates just fine, while the 2nd returns 404. This is confusing because ModelViews are not affected in the same way
Environment (please complete the following information):
Additional context
App being mounted is a FastAPI instance