#30843: New argument for FileField and descendants: size_field.
-------------------------------------+-------------------------------------
Reporter: Maksim Iakovlev | Owner: nobody
Type: New feature | Status: closed
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):
* status: new => closed
* resolution: => wontfix
* component: Uncategorized => Database layer (models, ORM)
Comment:
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 of
`FileField.size`, e.g.
{{{
@cached_property
def file_size(self):
return self.file.size
}}}
You can also create a custom field:
{{{
class MyFileField(FileField):
@cached_property
def custom_size_attribute(self):
return self.size
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/30843#comment:1>
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/067.19fdfa9afc1f9ab73fc93e26623d8671%40djangoproject.com.