Closed levic closed 9 years ago
I think there may be the same issue for CheckboxInput widget (the only one inheriting from 2 classes). That may be why its __init__
and value_from_datadict
are copy/pasted from the original one. (value_from_datadict
is actually a bit different).
I just realized widgets are actually a bit trickier because Input
is actually quite different from the django one.
Hi, I added some tests to the testsuite to check how the cleaning of the DateTimeField works. Please see this commit: https://github.com/gregmuellegger/django-floppyforms/commit/e78a32f58f88166cccc693fc7e0c744ac498c606
The test passes this test so I cannot verify your concerns. I also checked in the console the following:
In [1]: import floppyforms as forms
In [2]: forms.DateTimeField.mro()
Out[2]:
[floppyforms.fields.DateTimeField,
floppyforms.fields.Field,
django.forms.fields.DateTimeField,
django.forms.fields.BaseTemporalField,
django.forms.fields.Field,
object]
In [3]: forms.CheckboxInput.mro()
Out[3]:
[floppyforms.widgets.CheckboxInput,
floppyforms.widgets.Input,
floppyforms.widgets.Widget,
django.forms.widgets.CheckboxInput,
django.forms.widgets.Widget,
django.forms.widgets.NewBase,
object]
So it seems that the method-resolution-order is correct and doesn't impose the problem you were expecting to be the root of your problem. So I think we can exclude this as a reason for your problem, but maybe we need to investigate further.
Do you have more details about your issue? With what version of django-floppyforms did you test this?
I'm closing off this issue because I don't have enough information to reproduce. Please feel free to re-open it if you this still bugs you.
The definition for DateTimeField is
The problem is that django's DateTimeField overrides
to_python()
.Because
floppyforms.Field
is first in the inheritance hierarchy, theto_python()
fromdjangoforms.Field
wins overdjangoforms.DateTimeField
which means that you never end up with a submitted date value converted to adatetime
object (and then validation fails)I think
floppyforms.Field
should be a mixin and not inherit from anything