#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.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" 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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/055.672f6fa60fd6b84c4e57db79cad572d4%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to