#29607: Add doc examples of handling files and their lifecycles with FileField/models -------------------------------------+------------------------------------- Reporter: Thomas Grainger | Owner: Chris Type: | Adams Cleanup/optimization | Status: assigned Component: Documentation | Version: 2.0 Severity: Normal | Resolution: Keywords: | Triage Stage: Accepted Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------------+------------------------------------- Changes (by Chris Adams):
* status: new => assigned * cc: Chris Adams (added) * owner: nobody => Chris Adams Comment: I'm happy to have a go at this. I'm started in this branch here, adding some docs for common use cases outlined above: - set a file by passing the file path to the instance - set a file by making a brand new file with ContentFile - update a file by opening in a context manager, editing the file in memory then saving - work with a large file, using the __iter__ in a loop - work with a large file, in chunks, using chunks() I wasn't sure what this referred to though - can you give me any pointers? > cleaning up the FieldFile so that other code that accesses the file still works https://github.com/django/django/pull/11227 For what it's worth, I'm really in favour of the pathlib `instance.file.read()` syntax as outlined above - not having to faff with context managers is really nice syntactic sugar. -- Ticket URL: <https://code.djangoproject.com/ticket/29607#comment:3> 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/067.299c91885952bd9ec6c07f00a7f245ff%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.