Why does SelectDateWidget ignore empty_label when field is required?

26 views
Skip to first unread message

Aaron Scruggs

unread,
Jun 28, 2019, 8:35:09 AM6/28/19
to Django users
Greetings,

I have a ModelForm with a required date field that I am using SelectDateWidget with. I would like to default the select fields to empty placeholder values and force the user to pick a specific date, rather than defaulting to the first possible one. However when I pass empty_label to the widget the values are ignored, since the field is required. I could probably sub-class SelectDateWidget and change it to get the behavior I'm looking for, but after looking at the code and documentation it's clear that the current behavior is a deliberate choice. My question is: Why are placeholders ignored when the date field is required?

My use case doesn't seem that unusual so I'm guessing there's a strong reason why it's not supported. I'd love to know what that reason is before I go making a mess of things. Any help is much appreciated.

Thanks,

Aaron
Reply all
Reply to author
Forward
0 new messages