Skip to content

maxDate option does not work when field is referenced in range_from #125

@egong340

Description

@egong340

Describe the bug
I have 2 fields in my django form, start_date and end_date. The "end_date" field uses the range_from setting with a maxDate option (this works fine).
However, the "start_date" field, despite having the maxDate options, it does not set the maxDate when rendered.

    start_date = forms.DateField(
        required=True,
        widget=DatePickerInput(
            attrs={"autocomplete": "off"},
            options={
                "useCurrent": False,
                "showTodayButton": False,
                "maxDate": yesterday.strftime("%Y-%m-%d"),
                "allowInputToggle": True,
            },
        ),
    )
    end_date = forms.DateField(
        widget=DatePickerInput(
            attrs={"autocomplete": "off"},
            options={
                "useCurrent": False,
                "showTodayButton": False,
                "maxDate": yesterday.strftime("%Y-%m-%d"),
                "allowInputToggle": True,
            },
            range_from="start_date",
        ),
    )

Expected behavior
Both start_date and end_date should have a maxDate set before any dates are picked. However, only the end_date field has the maxDate set properly and start_date only reflects the date range correctly if end_date is picked first.

Screenshots
Start Date (today is Jan 24, 2025):
Image

Setup Information (please complete the following information):

  • OS: RHEL 9
  • Browser: Firefox
  • Browser version: 128.5.1esr (64-bit)
  • Python version: 3.11.10
  • Django version: 5.1.2
  • Bootstrap version: 4
  • jQuery version: 3.7.0

[x] I have followed the configuration instructions and checked out the
common error troubleshooting page.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions