*Django 1.11.2*
I'd like to use SelectDateWidget.
class FrameDate(models.Model):
through_date = models.DateField(null=True,
blank=True,
verbose_name=_("through"))
...
class FrameDateForm(ModelForm):
def clean_through_date(self):
pass # Breakpoint
class Meta:
model = FrameDate
exclude = []
years = range(1800, datetime.datetime.now().year + 1)
widgets = {
'frame': forms.HiddenInput(),
'from_date': forms.SelectDateWidget(years=years),
'through_date': forms.SelectDateWidget(years=years)
}
As we can see, this DateField is not required. And have an empty choice at
the top of the list ("---").
The problem is that when a user inputs only a month we'll get ValueError
springing out to the user in case of Debug=True.
There is that method clean_through_date and the break point in it. But in
case of incomplete set of month, day and year the program will not even
call this clean_through_date() method. This method is called in two cases:
1) if the through_date is completely empty.
2) if it is completely filled.
If it is partially filled, form validation is ignored completely. The
program explodes at CreateView.
*Could you comment on it? And give me a kick here: how to warn the user
that s/he must either fill month, day and year or don't touch the
through_date at all.*
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/24eabfb2-fe89-48a7-bce9-9bd7f6aa849b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.