#11228: FieldFile with check if file exists. -------------------------------------+------------------------------------- Reporter: hersonls | Owner: nobody Type: New feature | Status: closed Component: Database layer | Version: master (models, ORM) | Severity: Normal | Resolution: wontfix Keywords: | Triage Stage: Design | decision needed Has patch: 1 | Needs documentation: 1 Needs tests: 1 | Patch needs improvement: 1 Easy pickings: 0 | UI/UX: 0 -------------------------------------+------------------------------------- Changes (by litchfield):
* cc: litchfield (added) Comment: Sorry to re-open, but the notion that an error is raised when attempting to access attributes on a missing file is a wildly impractical default. It assumes that "everyone at all times will have a full, up-to-date copy of the media folder, that is exactly in sync with the database they're running against". If you're coding in a little bubble, eg pre-launch, against some bollocks test data-- sure, lets raise errors and annoy ourselves. But in the "real world" this is often/usually not the case and means you have to move around massive media libraries and databases just to work on the site at all, without resorting to temporarily commenting stuff out or hacking up a custom field. The default should be to return None, overridable through the field/model definition (eg silent=False). And there should be an exists() method too, why not? @aaugustin your presumption above "that you have bigger problems" is totally irrelevant in many production scenarios. -- Ticket URL: <https://code.djangoproject.com/ticket/11228#comment:5> Django <https://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 unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/066.071897a2d0e406327951fe981af8cdf1%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.