【问题标题】:how to add images to database in django with out showing the path of images in choosen button如何在 django 中将图像添加到数据库中而不在选择的按钮中显示图像的路径
【发布时间】:2021-07-13 15:01:45
【问题描述】:

我有以下表格:

class ProductForms(forms.ModelForm):
    images1 = forms.ImageField(widget=forms.FileInput,)
    class Meta:
        model = Product
        fields =  '__all__'

如何才能使图像的路径不显示在呈现的 html 中?

【问题讨论】:

    标签: python django django-forms


    【解决方案1】:
    <input type="file" name="picture" />
    

    使用这个,但是按照你在模型中写的名称更改

    【讨论】:

      【解决方案2】:

      你需要修改你的css,比如:

      css-selector-here {
          display: none;
      }
      

      为了不显示该 UI 元素。您也可以通过修改模板来执行此操作,但我不会。这更清洁,更容易。

      【讨论】:

        猜你喜欢
        • 2013-05-29
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-11-25
        • 2015-08-07
        • 1970-01-01
        • 2015-02-12
        • 1970-01-01
        相关资源
        最近更新 更多