ImageField width and height fields are not populated in child models. #786
Unanswered
brocksamson
asked this question in
Q&A
Replies: 1 comment
-
|
This is an upstream issue with Django and is outside of django-polymorphic's scope to fix. You could fix this in your app's ready() method. Explicitly connect update_dimension_fields to the post_init signal for all child models. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Say we have the following model structure:
The image_width and image_height fields will not be correctly filled out when reading a UserEvent (via UserEvent.objects.get or similar) from the db. This is because of how the
contribute_to_classmethod works on the ImageField class. Here is the code for that method:The issue is the
sender=clswithin the connect. If you inspect cls within this method you find that the contribute_to_class is called for the Event model, but it is not called for the UserEvent model. This results in the post_init signal only being wired for the Event model, not the UserEvent model.Making Event abstract will cause contribute_to_class to be called for UserEvent, but that isn't what I want.
Beta Was this translation helpful? Give feedback.
All reactions