summaryrefslogtreecommitdiff
path: root/django/db/models/fields/files.py
AgeCommit message (Collapse)Author
2026-04-14Fixed #27150 -- Made base File objects truthy by default.VIZZARD-X
2025-10-15Fixed 36622 -- Prevented LazyObject FileField storages from evaluating at ↵Clifford Gama
boot time. Co-authored-by: Fabien MICHEL <fmichel@adista.fr>
2025-07-23Refs #36500 -- Rewrapped long docstrings and block comments via a script.django-bot
Rewrapped long docstrings and block comments to 79 characters + newline using script from https://github.com/medmunds/autofix-w505.
2025-07-23Removed double spaces after periods and within phrases.Sarah Boyce
2025-01-20Fixed #36005 -- Dropped support for Python 3.10 and 3.11.Mariusz Felisiak
2024-08-05Fixed #35657 -- Made FileField handle db_default values.Sarah Boyce
2024-05-22Fixed #35139 -- Prevented file read after ImageField is saved to storage.John Parton
2024-05-15Fixed #35384 -- Raised FieldError when saving a file without a name to ↵Jonny Park
FileField.
2023-06-19Refs #34517 -- Restored skipping ImageFileField.update_dimension_fields ↵François Freitag
without width/height fields. This avoids reading the image size when the dimensions fields (image_width, image_height) do not exist, as that operation may be expensive. Partially reverts ea53e7c09f1b8864c20c65976bbeaeab77abdaec, that dropped the check for the dimension fields in update_dimension_fields(), because the post_init signal was no longer registered without dimension fields. However, another code path to that function exists: when the ImageFileField is save()d, the name from the storage is setattr()ed on the field, and ImageFileDescriptor calls update_dimension_fields() because the image size might have changed. Keep bailing out early when dimensions are unused. Besides, computing the image dimensions causes to close() the file, resulting in a backward-incompatible change. The test protects against that change.
2023-05-03Fixed #34517 -- Avoided connection post_init signal to ImageField without ↵Orhan Hirsch
width/height fields.
2023-02-01Refs #33476 -- Applied Black's 2023 stable style.David Smith
Black 23.1.0 is released which, as the first release of the year, introduces the 2023 stable style. This incorporates most of last year's preview style. https://github.com/psf/black/releases/tag/23.1.0
2023-01-23Fixed #34192 -- Preserved callable storage when it returns default_storage.Matt Westcott
2022-11-04Fixed #27654 -- Propagated alters_data attribute to callables overridden in ↵LightDiscord
subclasses. Thanks Shai Berger and Adam Johnson for reviews and the implementation idea.
2022-08-25Fixed typo in django/db/models/fields/files.py comment.Jan Pieter Waagmeester
2022-02-07Refs #33476 -- Refactored code to strictly match 88 characters line length.Mariusz Felisiak
2022-02-07Refs #33476 -- Reformatted code with Black.django-bot
2021-05-13Fixed #32718 -- Relaxed file name validation in FileField.Mariusz Felisiak
- Validate filename returned by FileField.upload_to() not a filename passed to the FileField.generate_filename() (upload_to() may completely ignored passed filename). - Allow relative paths (without dot segments) in the generated filename. Thanks to Jakub Kleň for the report and review. Thanks to all folks for checking this patch on existing projects. Thanks Florian Apolloner and Markus Holtermann for the discussion and implementation idea. Regression in 0b79eb36915d178aef5c6a7bbce71b1e76d376d3.
2021-05-04Fixed CVE-2021-31542 -- Tightened path & file name sanitation in file uploads.Florian Apolloner
2020-10-12Fixed #32098 -- Made FieldFile use FileField.attname.Sultan
After a93425a37f4defdb31d4ca96bb3bf6da21f0b5ce FileDescriptor is a subclass of DeferredAttribute and uses FileField.attname to access the field data, so that custom subclasses can not only save data to files, but also represent the same data with a different data type by attaching FileFiled.name to a particular descriptor. Follow up to a93425a37f4defdb31d4ca96bb3bf6da21f0b5ce.
2020-09-02Fixed #31941 -- Corrected FileField.deconstruct() with a callable storage.Brian Helba
2020-07-24Fixed #31812 -- Fixed FileField.model for fields defined in abstract models.Matthias Kestenholz
Regression in a93425a37f4defdb31d4ca96bb3bf6da21f0b5ce.
2020-06-30Fixed #31701 -- Made FileDescriptor subclass DeferredAttribute.alosultan
2020-06-15Fixed #31706 -- Removed unnecessary getattr() call in FileDescriptor.__get__().Sultan
refresh_from_db() loads fields values.
2020-04-08Fixed #28184 -- Allowed using a callable for FileField and ImageField storage.miigotu
2020-01-09Fixed #21238 -- Fixed restoring attributes when pickling FileField and ↵Hasan Ramezani
ImageField.
2019-08-18Refs #28428 -- Made FileField.upload_to support pathlib.Path.Claude Paroz
2019-04-18Fixed #30367 -- Changed "pip install" to "python -m pip install" in docs, ↵Ramiro Morales
comments and hints.
2019-01-27Removed default mode='r' argument from calls to open().Jon Dufresne
2018-04-17Fixed #29334 -- Updated pypi.python.org URLs to pypi.org.Brett Cannon
2018-01-03Fixed #28982 -- Simplified code with and/or.Дилян Палаузов
2018-01-03Fixed #28984 -- Made assorted code simplifications.Tim Graham
2018-01-03Fixed #28985 -- Removed unneeded None checks before hasattr().Дилян Палаузов
2017-12-11Fixed #28909 -- Simplified code using tuple/list/set/dict unpacking.Nick Pope
2017-12-04Fixed #28873 -- Used dict.setdefault() to set model and form field defaults.Дилян Палаузов
2017-06-01Fixed #28242 -- Moved ImageField file extension validation to the form field.Manatsawin Hanmongkolchai
2017-04-07Fixed #27777 -- Made File.open() work with the with statement (#8310)Ingo Klöcker
Fixed #27777 -- Made File.open() work with the with statement
2017-03-04Refs #27795 -- Removed unneeded force_text callsClaude Paroz
Thanks Tim Graham for the review.
2017-02-28Refs #27656 -- Updated django.db docstring verbs according to PEP 257.Anton Samarchyan
2017-02-28Removed obsolete references to form_for_instance().Tim Graham
2017-02-07Converted usage of ugettext* functions to their gettext* aliasesClaude Paroz
Thanks Tim Graham for the review.
2017-01-26Refs #23919, #27778 -- Removed obsolete mentions of unicode.Vytis Banaitis
2017-01-25Refs #23919 -- Replaced super(ClassName, self) with super().chillaranand
2017-01-20Refs #23919 -- Removed unneeded str() callsClaude Paroz
2017-01-20Refs #23919 -- Removed unneeded force_str callsClaude Paroz
2017-01-19Refs #23919 -- Stopped inheriting from object to define new style classes.Simon Charette
2017-01-18Refs #23919 -- Removed obsolete __ne__() methods.Aymeric Augustin
__ne__() defaults to the opposite of __eq__() on Python 3 when it doesn't return NotImplemented.
2017-01-18Refs #23919 -- Removed six.<various>_types usageClaude Paroz
Thanks Tim Graham and Simon Charette for the reviews.
2017-01-17Refs #26058 -- Removed deprecated FileField.get_directory_name()/get_filename().Tim Graham
2016-11-30Refs #27358 -- Fixed system check crash with an empty FileField.upload_to.Lex Berezhny
2016-11-29Fixed #27358 -- Added a system check to prevent FileField's upload_to from ↵Henry Dang
starting with a slash. Thanks Frank Bijlsma for the initial patch.