I created web application. It contains 4 pages. I want to add functionality which includes pattern-matching and dcc.Store component. This function located in page 2 but dcc.Store component in page 1. In page 2 I created “n_click” variable. So I need use this variable in page 1. I imported page 2 as module to get “n_click” variable.
But I get error:
AttributeError: module ‘pages.pg2’ has no attribute ‘n_clicks_b’
Please, help me to find the way to use variable from another page
you can put the dcc store on the main page and access it from the subpages
Also, try with the basic examples as provided in the doc (store and sharing state) as a starting point.
@Sanan009 , please don’t create various topics asking the same thing.
This code located in pg2.py
def parse_contents_1(contents, filename, date, n_clicks_b):
content_type, content_string = contents.split(',')
decoded = base64.b64decode(content_string)
if 'csv' in filename:
# Assume that the user uploaded a CSV file
df = pd.read_csv(
nfile[filename] = df.to_dict('records')
elif 'xls' in filename:
Did you try what I suggested? I really think what you are trying to do is not necessary.
You could create a MRE. This increases your chances to get help drastically.
Adding a minimal reproducible example to your questions will help attract community members to answer your question. The goal of writing a MRE is to allow other members of the community to run the code on their computers and “reproduce” the error, so that they can best help you.
Please make sure that your MRE includes data and that the code is correctly pre-formatted.
To preformat, copy and paste the code in your post and then click on </> (Preformatted text), as shown on the image:
No, I know this method. But it is not solution for my problem.
in my application dcc.Store located in main page. So I need use variable from one page to another page
Hi, I don’t also want to create various topics asking the same thing. But I haven’t found any solution about my problem yet. Please help me to find it.