﻿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
13560	SplitDateTimeField(localize=True) fails as value gets converted to string	David Danier <david.danier@…>	nobody	"I tried the new localization-features in Django 1.2, activating localozation for all my fields in the admin using (why isn't this done by default anyway?):
{{{
class FooAdmin(admin.ModelAdmin):
	def get_form(self, *args, **kwargs):
		form_class = super(SSDAdmin, self).get_form(*args, **kwargs)
		for f in form_class.base_fields:
			form_class.base_fields[f].localize = True
		return form_class
}}}

After doing so my admin fails badly (meaning: Exception), I am not able to edit any models any more. After digging aroung for some time I found, that forms.BoundField converts the value to it's localized string before passing it to the field/widget (as_widget()). So SplitDateTimeWidget gets a string instead of the expected datetime-object and fails when trying to split date/time.

Simple test:
{{{
from django import forms
from datetime import datetime


class TestForm(forms.Form):
    datetime = forms.SplitDateTimeField(localize=True)


form = TestForm(initial={'datetime': datetime.now()})
print form['datetime']
}}}

I think this could be fixed by overwriting the localize_value() method of SplitDateTimeField to always return the vanilla data. I'll append a patch doing so, but I am not sure if this is enough/appropriate.

I could think of some more dependancies MultiValueField's doesn't meet yet. For example I think field.localized should be set for every field in MultiValueField.fields, according to the value used in MultiValueField.localized.
"		closed	Forms	1.2		fixed	localization, SplitDateTimeField, regression		Ready for checkin	1	0	0	0	0	0
