Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

228
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda