Replies: 6 comments
-
What kind of data are we talking about here, maybe writing your own backend for the data you're talking about could be a solution. It could be a pandas data frame, a list of records from Beanie ODM, list of dictionaries etc. I guess I have misunderstood. I'm eager to see a solution. One thing in mind, you can edit the function that returns the get list query, it's in |
Beta Was this translation helpful? Give feedback.
-
Let's say that I want to print 5 attributes of the current user which are in the User table. How can I do this from the index.html template? I have the userId from the session, but I need to read this record and use the fields. |
Beta Was this translation helpful? Give feedback.
-
I just realized that I can pass a custom index_view in the constructor. I will try that for now. See if I can override the queries or something. The default is a CustomView and it has this:
|
Beta Was this translation helpful? Give feedback.
-
I managed to create my own subclass of CustomView and overrode render in it and it all worked fine. |
Beta Was this translation helpful? Give feedback.
-
What kind of data are we talking about here, maybe writing your own backend for the data you're talking about could be a solution. That's great, can you share a minimal example with us? |
Beta Was this translation helpful? Give feedback.
-
a complete example is available in the demo, which can be found at https://github.com/jowilf/starlette-admin-demo/blob/d7c446743d81fc4ae76514c1b208e0f122733c98/app/sqla/views.py#L102. |
Beta Was this translation helpful? Give feedback.
-
Is your feature request related to a problem? Please describe.
I want to show a "summary for your tenant" on the main page. I have the ID of the logged user in the session, which means I could make a SQLALchemy query and fetch the data for summarizing some stuff on the front page. Or show a LOGO for the tenant (say that User belongs to a COMPANY and the company has a logo/PNG in the database).
How can I do this? I already overrode the index.html template with static data:
The problem is how to make this override dynamic.
I have already done dynamic overrides in the templates where I have a record/entity being shown ("detail" and "edit"). But index.html is different - all I have potentially is the logged user. What do I need to override to pass data to my template? How can I pass a dataset to index.html?
Describe the solution you'd like
A way to pass a dataset to index.html. It could be a python method where I define the query. Very much like get_list_query_for_request and get_list_count_for_request, but in this case not for the list, but for the home page itself.
Describe alternatives you've considered
Additional context
None
Beta Was this translation helpful? Give feedback.
All reactions