Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

227
Views
Dash datepicker max_date_allowed as current date not working properly

I am using dash for my dashboard and is deployed on AWS Elastic Beanstalk.
There is an issue in Datepicker.I am using max_date_allowed=dt.date(dt.now())

So the day the app is deployed everything worked fine. But from the next day, the max_date_allowed is stuck to the date, the app is deployed and we can't choose date beyond the date the app is deployed.
It works again only if we choose in the environment, restart app server(s) from the action menu.

What could be the issue here?

Below is the date picker snippet we used.

dcc.Tabs([
        dcc.Tab(label='DDR by Date (Default DDR - Last Day)', value='tab-1', children=[
            dcc.DatePickerSingle(
                id='my-date-picker-single',
                min_date_allowed=dt(2020, 1, 18),
                max_date_allowed=dt.date(dt.now()),
                initial_visible_month=dt.date(dt.now()),
                placeholder='Select a date',
                display_format='DD/MM/YYYY'
            ),
            html.Button(id='submit-button', n_clicks=0, children='Submit'),
            html.Div(id='output-container-date-picker-single')
        ]),
over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Assuming that the code snippet is part of the app layout definition, the behavior you see is intended. This code is executed when the app starts, and dt.date(dt.now()) is thus evaluated at this time only.

There are (at least) two common ways to achieve what you want,

  • Wrap your layout definition in a function and assign the function instance as the app layout. The code would be something like app.layout = make_my_layout_function. By assigning a function, the app layout code will be evaluated each time a user visits you page. See more details in the documentation (scroll to "Updates on Page Load").

  • Assign the non-static default value, in your case max_date_allowed, via a callback. Since callbacks are executed on page load (unless you actively prevent it), the value will be updated as intended.

over 4 years ago · Santiago Trujillo Report

0

My approach to this would be to use an interval

Set the interval to fire say every hour and then use a callback to update the max_date_allowed

Taking this approach will eliminate the requirement for the user to reload the page to update

e.g.

@app.callback(Output("date-picker", "max_date_allowed"),
              [Input("interval_hours", "n_interval")])
def update_max_date_allowed(n):
    return dt.date(dt.now())
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!