Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#11672 closed (invalid)

using forms.DateField or forms.DateTimeField causes validation error on fields that should be optional

Reported by: Skylar Saveland <skylar.saveland@…> 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: UI/UX:

Description (last modified by Alex)

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',),
    class Meta: 
        model = Event

submitting an empty field will cause a validation error.

Change History (5)

comment:1 Changed 6 years ago by Skylar Saveland <skylar.saveland@…>

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
class Event(models.Model):
    end = models.DateTimeField?(blank=True, null=True) 

comment:2 Changed 6 years ago by Skylar Saveland <skylar.saveland@…>

Can someone throw away this ticket?
... I'm going to make a properly formatted one

comment:3 Changed 6 years ago by Alex

  • Description modified (diff)

Please use the preview button.

comment:4 Changed 6 years ago by dc

  • Resolution set to invalid
  • Status changed from new to closed

Use must use DateTimeField with DateTimeInput or SplitDateTimeField with SplitDateTimeWidget.

comment:5 Changed 6 years ago by dc

Duplicate of #8898

Note: See TracTickets for help on using tickets.
Back to Top