[Django] #26174: Validation fails for DateTimeField(widget= widgets.AdminSplitDateTime) in Django 1.9

9 views
Skip to first unread message

Django

unread,
Feb 4, 2016, 5:36:31 AM2/4/16
to django-...@googlegroups.com
#26174: Validation fails for DateTimeField(widget= widgets.AdminSplitDateTime) in
Django 1.9
------------------------------+-----------------------------
Reporter: Josh-Git-Hub | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 1.9
Severity: Normal | Keywords: form validation
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+-----------------------------
Validation for DateTimeField(widget= widgets.AdminSplitDateTime) fails in
Django 1.9. The validation raised says: ''"Enter a valid date/time."''

'''For Django 1.8 the validation is successful. Django 1.9 fails.'''

This is my form code:

{{{
from django import forms
from django.contrib.admin import widgets


class AddEventForm(forms.Form):
event_name = forms.CharField(max_length=30)
start_date = forms.DateTimeField(widget= widgets.AdminSplitDateTime)
}}}

This is the view:

{{{
from django.shortcuts import redirect, render_to_response, render
from django.views.generic.list import ListView
from .models import Events
from .forms import AddEventForm


class EventsListView(ListView):
model = Events


def new_event(request):
if request.method == 'POST':
form = AddEventForm(request.POST)
if form.is_valid():
save_data = form.cleaned_data
handler = Events(event_name=save_data['event_name'],
start_date=save_data['start_date'])
handler.save()
return redirect('../')
else:
form_errors = form.errors
return render_to_response('events/error.html', {'form_errors':
form_errors})

# if a GET (or any other method) we'll create a blank form
else:
form = AddEventForm()
return render(request, 'events/new_event_form.html', {'form':
form})
}}}

My model:

{{{
from django.db import models

# Create your models here.

class Events(models.Model):
def __str__(self):
return self.event_name
event_name = models.CharField(max_length=30)
start_date = models.DateTimeField()
}}}

I attached a sample project (Admin App admin:admin)

--
Ticket URL: <https://code.djangoproject.com/ticket/26174>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Feb 4, 2016, 5:37:07 AM2/4/16
to django-...@googlegroups.com
#26174: Validation fails for DateTimeField(widget= widgets.AdminSplitDateTime) in
Django 1.9
-----------------------------+----------------------------

Reporter: Josh-Git-Hub | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 1.9
Severity: Normal | Resolution:

Keywords: form validation | Triage Stage: Unreviewed
Has patch: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------+----------------------------
Changes (by Josh-Git-Hub):

* Attachment "TestApp.tar.gz" added.

SampleApp with validation error

Django

unread,
Feb 4, 2016, 5:48:03 AM2/4/16
to django-...@googlegroups.com
#26174: Validation fails for DateTimeField(widget= widgets.AdminSplitDateTime) in
Django 1.9
---------------------------------+-----------------------------------------
Reporter: Josh-Git-Hub | Owner: rfleschenberg
Type: Bug | Status: assigned
Component: Forms | Version: 1.9
Severity: Normal | Resolution:

Keywords: form validation | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+-----------------------------------------
Changes (by rfleschenberg):

* status: new => assigned
* needs_better_patch: => 0
* owner: nobody => rfleschenberg
* needs_tests: => 0
* needs_docs: => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/26174#comment:1>

Django

unread,
Feb 4, 2016, 5:57:27 AM2/4/16
to django-...@googlegroups.com
#26174: Validation fails for DateTimeField(widget= widgets.AdminSplitDateTime) in
Django 1.9
---------------------------------+-----------------------------------------
Reporter: Josh-Git-Hub | Owner: rfleschenberg
Type: Bug | Status: assigned
Component: Forms | Version: 1.9
Severity: Normal | Resolution:
Keywords: form validation | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+-----------------------------------------
Changes (by rfleschenberg):

* needs_tests: 0 => 1
* stage: Unreviewed => Accepted


Comment:

I can reproduce this. Looks like a regression to me. I will try to take a
closer look at this soon.

--
Ticket URL: <https://code.djangoproject.com/ticket/26174#comment:2>

Django

unread,
Feb 4, 2016, 11:18:20 AM2/4/16
to django-...@googlegroups.com
#26174: Validation fails for DateTimeField(widget= widgets.AdminSplitDateTime) in
Django 1.9
---------------------------------+-----------------------------------------
Reporter: Josh-Git-Hub | Owner: rfleschenberg
Type: Bug | Status: assigned
Component: Forms | Version: 1.9

Severity: Normal | Resolution:
Keywords: form validation | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+-----------------------------------------

Comment (by charettes):

I'm I remember correctly usage of `SplitDateTimeWidget` (and subclasses)
with `DateTimeField` is deprecated since Django 1.7.

Can you also reproduce using `SplitDateTimeField` instead of
`DateTimeField`?

--
Ticket URL: <https://code.djangoproject.com/ticket/26174#comment:3>

Django

unread,
Feb 4, 2016, 11:26:48 AM2/4/16
to django-...@googlegroups.com
#26174: Validation fails for DateTimeField(widget= widgets.AdminSplitDateTime) in
Django 1.9
---------------------------------+-----------------------------------------
Reporter: Josh-Git-Hub | Owner: rfleschenberg
Type: Bug | Status: closed
Component: Forms | Version: 1.9
Severity: Normal | Resolution: invalid

Keywords: form validation | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+-----------------------------------------
Changes (by timgraham):

* status: assigned => closed
* resolution: => invalid


Comment:

Correct, the 1.9 release notes say, "The ability to use a
`SplitDateTimeWidget` with `DateTimeField` is removed."

--
Ticket URL: <https://code.djangoproject.com/ticket/26174#comment:4>

Django

unread,
Feb 4, 2016, 11:48:53 AM2/4/16
to django-...@googlegroups.com
#26174: Validation fails for DateTimeField(widget= widgets.AdminSplitDateTime) in
Django 1.9
---------------------------------+-----------------------------------------
Reporter: Josh-Git-Hub | Owner: rfleschenberg
Type: Bug | Status: closed
Component: Forms | Version: 1.9

Severity: Normal | Resolution: invalid
Keywords: form validation | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+-----------------------------------------

Comment (by rfleschenberg):

Ooops, sorry. I had only checked the "Backwards incompatible changes"
section, not "Features removed" :)

--
Ticket URL: <https://code.djangoproject.com/ticket/26174#comment:5>

Reply all
Reply to author
Forward
0 new messages