Using height_field and width_field attribute in ImageField of Django

前端 未结 2 832
栀梦
栀梦 2021-02-05 16:04

I have a model

class Anh_chi_tiet(models.Model):
    du_an       = models.ForeignKey(Du_an)
    title       = models.CharField(max_length=120)
    url         =         


        
2条回答
  •  天命终不由人
    2021-02-05 16:19

    I think you are misunderstanding what the height_field and width_field attributes are for.

    The height_field isn't used to change the height. It's used to record what the height already is.

    This way you can do something like

     
    

    without having to read the file.

    If you are trying to resize all images uploaded via an ImageField, check here: Image resizing with django?

提交回复
热议问题