Opened 5 years ago
Closed 5 years ago
#30843 closed New feature (wontfix)
New argument for FileField and descendants: size_field.
Reported by: | Maksim Iakovlev | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
size_field
must work same as ImageField.width_field
, but for file size in bytes. It may be helpful in systems which use remote storages. For example, S3 storage from django-storages makes HEAD request for every file.size
call. It's painful sometimes.
Change History (1)
comment:1 by , 5 years ago
Component: | Uncategorized → Database layer (models, ORM) |
---|---|
Resolution: | → wontfix |
Status: | new → closed |
Summary: | New argument for FileField and descendants: size_field → New argument for FileField and descendants: size_field. |
Note:
See TracTickets
for help on using tickets.
Thanks for this report, however this looks like sth that should be fixed in
django-storages
. I don't see many use cases for this feature. You can always add a@cached_property
to your model to avoid multiple calls ofFileField.size
, e.g.You can also create a custom field: