Answer the question
In order to leave comments, you need to log in
How to save a value from one page and use it everywhere for filters in the database on other pages?
Good afternoon!
I have a 5 page web application. And there is also an authorized user (I use the flask-login module).
And I have the following problem: on 3 out of 5 pages, when loading content, you need to specify a filter in the database, according to which the data will be loaded. For the filter, you need to pass a parameter. How to get this parameter in advance so that it can be sent when loading pages? This parameter can be set on the page (p_1) or somewhere else.
I am attaching a small drawing to understand the situation visually.
There are such ideas/options, I don't know which of them is good:
1. Set this parameter on the p_1 page and write it to the database in the field for the user.
When loading the page, pull out this value and send it further for filtering.
Of the minuses: is it good or not very good to change such a parameter often? Unclear. And also get it from the database, and this is a +1 filter for users.
2. On the p_1 page, set this parameter and write it to the database in the field for the user.
Further, pages p_2, p_3 and p_4 are opened via a link with the format: link/param/link
But it seems to me that this is a more complicated option 1.
3. Add a variable to the user.
I don't know how to do it. Store on the server? Store in cookies? And use it.
4. Set a drop-down list in the header and set the parameter values in the drop-down list (so that the user can choose).
Where to store the value of this list? How to load the header first, so that later the content from the database?
5. Do not use the option now, first get all the content, and then apply a filter to it and filter and display the content.
My development is simple, the front on the back is somehow generated, with jinja. Probably not the best approach, but there is still no knowledge for a full-fledged front, and we need to work now.
What is a good way or something else? How to do it better?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question