I have a model that has a FileField storage field. The default_storage system is S3Storage. I noticed that I was getting unusual results when I simply tried to verify whether the file existed on disk using the default_storage.exists() method. If I call it with the FileField object, it causes Django to actually try to *get* the file, which is not what I intend. The S3Storage module implements exists() as a simple http HEAD request. That part works fine. But then Django starts getting the file which eventually results in an error, so it appears the file doesn't exist when really it does. (The file is an audio file, which triggers a series of byte-range requests, the final one having incorrect value, so I'm getting a series of 206 codes followed by 416 error code. It causes a key error in S3Storage or S3 on 'etag'.)
I was able to work around it by using the str() function, which results in the correct behavior. Anyway, it was non-intuitive for me that checking whether a file exists would make Django do a GET on it! Is this a bug or do I just not understand what's going on beneath the surface? (Which is the case, actually.) Can someone explain this? Liam > > section_objects = > Section.objects.in_bulk(section_ids).values() > if len(section_ids) != len(section_objects): > print "section count mismatch for article '%d'" % > (art.id) > idx = 0 > for sec in section_objects: > idx += 1 > if sec.url: > try: > if not default_storage.exists(*str*(sec.url)): > print "\tarticle '%s' missing content > for section %d" % (art.id, idx) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---