Thursday, June 27, 2019

Why does SelectDateWidget ignore empty_label when field is required?


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.



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 post to this group, send email to
Visit this group at
To view this discussion on the web visit
For more options, visit

No comments:

Post a Comment