datetime.date.today() in Django (Dash app)

The problem you’re having is that the code creating this Plotly Dash component is only being executed once, when the module is loaded (i.e. “the day that the django application was started”). You don’t show where this instantiation is happening so there’s not enough information to identify the precise cause. Perhaps you’ve factored out this component definition into a module-level variable for reuse? In any case, the solution is to make sure that the datepicker code gets called on every request.

Also, use Django’s localdate() function, not date.today(). The latter does not take Django’s settings (like TIME_ZONE) into account.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top