Opened 4 months ago

Last modified 4 months ago

#36384 closed Cleanup/optimization

update_dimension_fields blocks getting model instances from the database when the external storage has issues — at Initial Version

Reported by: Gerben Morsink Owned by:
Component: Database layer (models, ORM) Version: 5.1
Severity: Normal Keywords:
Cc: Gerben Morsink Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

It seems when a height_field or width_field are given, the update_dimension_fields is always called on initialization of the model instance. Thereby always doing a call to an external database if those fields are empty.

This might seem obvious, but it means that when and external storage is down, it is not possible anymore to get this Model instance anymore.

For example with S3 issue it might raise:

`
ClientError: An error occurred (403) when calling the HeadObject operation: Forbidden
`

even when I simply want to get the object without the width and height, like here:

`
UserAvatar.objects.get(user=user).only('id')
`

This is in my opinion an unexpected consequence of adding the height_field and width_field to an ImageField.
What do you think, should width and height be lazily loaded somehow?

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top