Replies: 1 comment
-
When creating the sessionmaker(
bind=view.engine,
class_=Session,
)
class DashboardView(BaseView):
name = "Dashboard View"
icon = "fa-solid fa-chart-line"
@expose("/dashboard", methods=["GET"])
def dashboard_page(self, request):
with self.sessionmaker(expire_on_commit=False) as session:
result = session.execute(stmt)
objects = result.scalars().unique().all()
return self.templates.TemplateResponse(
"dashboard.html",
context={"request": request,
"tx_timeline": objects,
}
) BTW this is not tested so there might be some mistakes in my code, but it should generally give you the idea as SQLAdmin is also using the same thing: |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Love this admin panel, great work!
I have a custom Dashboard view and want to make use of the jinja template engine bz passing on some data to the template.
What would I need to do to get the db session ( in fast api via db: Session = Depends(get_db) but that doesnt work here) to the dashboard_page ?
Beta Was this translation helpful? Give feedback.
All reactions