On Fri, Dec 9, 2011 at 11:49 AM, Florian Apolloner <f.apollo...@gmail.com> wrote: > > > On Thursday, December 8, 2011 11:36:53 PM UTC+1, Alex_Gaynor wrote: >> >> It isn't alreayd?!?! All file objects django exposes should be context >> managers, I thought I added that to a base mixin class a while ago, but >> apparently I didn't add it to the right thing. > > > Your memory serves you well ;) I wrote the patch and you commited it: > https://code.djangoproject.com/ticket/14749 We added it only to File though.
FieldFile inherits from File, though, so the methods are present. You just have to do: with obj.file_field as f: ... instead of calling the open() method (which returns None), as the OP tried. The only catch is that the __enter__ method does not open the file, so if you close the file and then try the above, you'll get an exception. -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com. To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.