#14039: FileField special-casing breaks MultiValueField including a FileField
---------------------------------+------------------------------------------
Reporter: carljm | Owner: carljm
Status: new | Milestone:
Component: Forms | Version: SVN
Resolution: | Keywords: sprintSep2010
Stage: Unreviewed | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 1 |
---------------------------------+------------------------------------------
Comment (by carljm):
Replying to [comment:3 radiac]:
> I have also had to add clean_takes_initial=True to
forms.fields.MultiValueField and modify its clean() function to test the
flag again, because that is responsible for cleaning the individual fields
(at least in 1.2.3, line 778).
Thanks for the patch review. I'm not sure that the base MultiValueField
implementation should add the complexity necessary to support
clean_takes_initial "out of the box". Simply testing the flag on member
fields is not enough, because without knowing the specific fields in
question I don't think it's possible to generically handle the initial
value correctly. The initial arg won't be a list, as the value arg is:
should the same initial value really be passed into any member field that
asks for an initial value? I don't think this is a valid assumption.
Rather, I think MultiValueField subclasses which want to invoke
clean_takes_initial behavior will probably have to override clean() anyway
and provide the specific initial-handling that makes sense for their case.
I'll leave the needs_better_patch flag on until we can get a third set of
eyes on this, but I think this patch is a useful (if minor) improvement
as-is: it makes it possible for subclasses to do the right thing, without
forcing them to inherit from a specific base class. If you think you can
provide a patch for MultiValueField that makes it automatically handle all
cases correctly with initial values, please do!
Git branch is at http://github.com/carljm/django/tree/ticket_14039
--
Ticket URL: <http://code.djangoproject.com/ticket/14039#comment:4>
Django <http://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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.