如何使用小部件在 Django Forms 中设置 ImageField 的样式

How to style a ImageField in Django Froms using widget

click to see image

Django 表单

How to style the Imagefield using widget in Django forms

你的问题不足以提供答案。请为此提供足够的代码或解释。

但要访问图像字段或设置样式,请使用以下代码:

from django import forms 

class ImageForm(forms.Form):
    image = forms.ImageField(
        widget = forms.FileInput(
            attrs = {"id" : "image_field" , # you can access your image field with this id for css styling . 
                    , style = "height: 100px ; width : 100px ; " # add style from here .
                    }
            )
      
    ....