#3297: newforms: Implement FileField and ImageField
---------------------------------------+------------------------------------
   Reporter:  [EMAIL PROTECTED]  |                Owner:  adrian         
     Status:  reopened                 |            Component:  django.newforms
    Version:  SVN                      |           Resolution:                 
   Keywords:  newforms                 |                Stage:  Accepted       
  Has_patch:  1                        |           Needs_docs:  0              
Needs_tests:  0                        |   Needs_better_patch:  0              
---------------------------------------+------------------------------------
Changes (by David Danier <[EMAIL PROTECTED]>):

 * cc: [EMAIL PROTECTED] (added)

Comment:

 As I think putting the current value out to the web could lead to issues
 and may not be secure enough (user can skip a required field or submit
 anything to the script, NEVER trust user-data).
 
 So I rewrote the patch, to not need this additional <input> anymore:
  * newforms.form_for_instance() sets formfield.required to False for every
 FileField that has some file attached
  * Forms that are written by the user should imitate this behavior if they
 want to use FileFields
    (perhaps a generic function can be added to newforms.models to
 accomplish this?)
 
 Note about the implementation:
 This can be done using a different variable, too. I tried using
 formfield.has_file_attached. But you have a problem here with
 newforms.Field.clean(). It checks whether the value is in EMPTY_VALUES and
 raises an Exception regardless of formfield.has_file_attached. So you have
 to skip super(FileField, self).clean(value), which I considered hackish.
 (You could set self.required before calling this and reset it afterwards,
 but I think this is worse.)
 
 I tried to update the tests as well, but am not sure if they work (No clue
 how to call them).
 
 Attachment follows.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/3297#comment:31>
Django Code <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
-~----------~----~----~----~------~----~------~--~---

Reply via email to