ImageField: height_field and width_field option sometimes doesn't work
|Reported by:||Lehych||Owned by:||Jacob|
|Severity:||Keywords:||ImageField, height_field, width_field|
|Cc:||Armin Ronacher||Triage Stage:||Accepted|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
I had a problem: height_field and width_field always = 0 in some models, after uploading any image file.
Problem was in fields order: if height_field and width_field goes before image field - this thing happends.
I appears in models save method.
/django/db/models/base.py : 378 (actual for revision: 9962)
values = [(f, None, f.get_db_prep_save(raw and getattr(self, f.attname) or f.pre_save(self, False))) for f in non_pks]
here all fields values are calculated (get_db_prep_save) and copy to values. So, if in models description ImageField goes before height and width fields, everything is fine. But if ImageField goes after this fields, all pic size calculation still in fields but not in values list.
Change History (16)
comment:1 Changed 8 years ago by
|Patch needs improvement:||unset|
|Triage Stage:||Unreviewed → Accepted|
comment:6 Changed 7 years ago by
|Owner:||changed from nobody to Armin Ronacher|
|Status:||reopened → new|
comment:10 Changed 7 years ago by
|Owner:||changed from Armin Ronacher to Jacob|
|Status:||new → assigned|