#11672 closed (invalid)
using forms.DateField or forms.DateTimeField causes validation error on fields that should be optional
| Reported by: | Owned by: | nobody | |
|---|---|---|---|
| Component: | Forms | Version: | 1.1 |
| Severity: | Keywords: | modelform date | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description (last modified by )
If you have a model like:
class Event(models.Model):
...
end = models.DateTimeField(blank=True, null=True)
...
and a modelform like:
from django import forms
from events.models import Event
class EventForm(forms.ModelForm):
end = forms.DateTimeField(('%m/%d/%Y %H:%M',),
widget=forms.SplitDateTimeWidget(
date_format='%m/%d/%Y',
time_format='%H:%M',
),
required=False
)
class Meta:
model = Event
submitting an empty field will cause a validation error.
Change History (5)
comment:1 by , 16 years ago
comment:2 by , 16 years ago
Can someone throw away this ticket?
... I'm going to make a properly formatted one
comment:4 by , 16 years ago
| Resolution: | → invalid |
|---|---|
| Status: | new → closed |
Use must use DateTimeField with DateTimeInput or SplitDateTimeField with SplitDateTimeWidget.
Note:
See TracTickets
for help on using tickets.
class Event(models.Model): ... end = models.DateTimeField?(blank=True, null=True) ...