Friday, January 22, 2021

Re: Django django_filters DateFilter customization

Hi Maynak,

On 22/01/2021 21.34, Mayank Tripathi wrote:
> Hi All,
> I am look for a solution where I can restrict the user to select date
> from current month only instead of selecting any other month or year.
> Currently user can select past month as well, have to restrict for
> current month only in date picker.

It seems like the HTML date input field has attributes for setting the
min and max value:

Setting these attributes to the first and last day of the month for the
widget ought to work:

Of course, you still need to ensure that the client doesn't send an
invalid/unexpected date.

I haven't tested this, but that's what I'd try to do at least.

Hope that helps.

Kind regards,

Kasper Laudrup

You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit

No comments:

Post a Comment