#15963: Misleading FileField.save documentation, no reference to
django.core.files.File
----------------------------------+-------------------------------
 Reporter:  ejucovy               |          Owner:  nobody
     Type:  Cleanup/optimization  |         Status:  new
Milestone:                        |      Component:  Documentation
  Version:  1.3                   |       Severity:  Normal
 Keywords:                        |   Triage Stage:  Unreviewed
Has patch:  1                     |  Easy pickings:  1
----------------------------------+-------------------------------
 The documentation for `FileField.save`
 
(http://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.FieldFile.save)
 claims:

 > Takes two required arguments: name which is the name of the file, and
 content which is a file-like object containing the file's contents.

 This is incorrect; `content` is *not* a "file-like object" -- it's a
 `django.core.files.File`-like object.

 Attempting to do `field.save(name, open(my_file))` results in an
 `AttributeError: 'file' object has no attribute 'chunks'`.  The correct
 spelling is instead `field.save(name,
 django.core.files.File(open(my_file)))`.

 I've attached a patch to the docs which makes this clear, and also refers
 the reader to the documentation about Django File objects.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/15963>
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 django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to