#3297: newforms: Implement FileField and ImageField
-------------------------------------+--------------------------------------
Reporter: [EMAIL PROTECTED] | Owner: adrian Type: defect | Status: reopened Priority: normal | Milestone: Version 1.0 Component: django.newforms | Version: SVN Severity: normal | Resolution: Keywords: newforms | -------------------------------------+--------------------------------------
Changes (by guioum):

 * status:  closed => reopened
 * resolution:  worksforme =>

Comment:

FYI:
{{{
>>> File._meta.fields[2].name
'data'
>>> File._meta.fields[2]
<django.db.models.fields.FileField object at 0xb778c6ac>

>>> f = forms.models.form_for_model(File).fields['data']
>>> f.widget
<django.newforms.widgets.TextInput object at 0xb66ebb2c>
>>> f.widget.input_type
'text'
}}}

Even with this small patch in "db/models/fields/__init__.py:
{{{
class FileField(Field):
...
    def formfield(self, initial=None):
        return forms.CharField(required=not self.blank,
widget=forms.FileInput, label=capfirst(self.verbose_name),
initial=initial)
}}}

... the field doesn't pass the validation. Output for the !FileField was
in oldforms:
{{{
<tr><th><label for="id_data_file">Data:</label></th><td><input type="file"
id="id_data_file" name="data_file" /><input type="hidden" id="id_data"
name="data" value="" /></td></tr>
}}}
(don't we need the hidden input in newforms?)

This is what I have in my template:
{{{
<form enctype="multipart/form-data" action="" method="post">
  <table class="form">
    {{ form }}
  </table>
  <input type="submit" value="Add File" />
</form>
}}}

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