﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
6626	newforms-admin DateField populated value wrong	Dan <danielnaab@…>	nobody	"With the admin in newforms-admin, DateFields are getting populated with the complete datetime string including hours, minutes, seconds.  This causes validation to fail on subsequent saves because that datetime format is not part of DateFields default input_formats.

To reproduce:
\
{{{
class MyModel(models.Model):
    date = models.DateField()

Create an instance of MyModel with a valid date in the admin.  Save.  Reload and save again, and date validation will fail.  Looking at the contents of the date's field in the form, you'll see that it's postfixed with 00:00:00 (you may have to right-arrow over to catch it... in Safari I do).

I've come up with a workaround that may be of use to some people.  In MyModel's ModelAdmin, place:
{{{
    def formfield_for_dbfield(self, db_field, **kwargs):
        if db_field.name == u'date_in':
            MY_DATE_INPUT_FORMATS = (
                # here's our custom input to handle the time that is getting added at the end of the widget:
                '%Y-%m-%d',                         # '2006-10-25'
                '%Y-%m-%d %H:%M:%S',                # '2006-10-25 00:00:00'
            )
            field = super(CanvasserResultsOptions, self).formfield_for_dbfield(db_field, **kwargs)
            field.input_formats = MY_DATE_INPUT_FORMATS
            return field
        return super(CanvasserResultsOptions, self).formfield_for_dbfield(db_field, **kwargs)
}}}

This simply overrides the input_formats to the two formats the admin interface might encounter."		closed	contrib.admin	newforms-admin		worksforme			Unreviewed	0	0	0	0	0	0
