我有一个图片栏
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<ns1:GetActiveSuppliersResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://webservice">
<GetActiveSuppliersReturn soapenc:arrayType="ns2:webservice.supplierdto[3]" xsi:type="soapenc:Array" xmlns:ns2="http://DefaultNamespace" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
<GetActiveSuppliersReturn href="#id0"/>
<GetActiveSuppliersReturn href="#id1"/>
<GetActiveSuppliersReturn href="#id2"/>
</GetActiveSuppliersReturn>
</ns1:GetActiveSuppliersResponse>
<multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns3:webservice.supplierdto" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns3="http://DefaultNamespace">
<asl_status xsi:type="xsd:string">Archived</asl_status>
<zip xsi:type="xsd:string">11735</zip>
</multiRef>
<multiRef id="id2" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns4:webservice.supplierdto" xmlns:ns4="http://DefaultNamespace" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
<asl_status xsi:type="xsd:string">Archived</asl_status>
<zip xsi:type="xsd:string">92880</zip>
</multiRef>
<multiRef id="id1" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns5:webservice.supplierdto" xmlns:ns5="http://DefaultNamespace" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
<asl_status xsi:type="xsd:string">Archived</asl_status>
<zip xsi:type="xsd:string">91355</zip>
</multiRef>
</soapenv:Body>
</soapenv:Envelope>
并使用视图
avatar = models.ImageField(upload_to="avatar", null=True, blank=True)
以模板形式
class EditView(SuccessMessageMixin, UpdateView):
model = MysiteUser
form_class = MysiteUserForm
pk_url_kwarg = 'pk'
template_name = 'update_form.html'
success_url = '/myprofile/'
success_message = "Zmiany zostały wprowadzone."
def form_valid(self, form):
image_to_del = MysiteUser.objects.get(username=form.instance)
print("Na dysku plik", image_to_del.avatar)
print("Formularz i pole 'avatar'", form.instance.avatar)
if form.instance.avatar != self.request.user.avatar:
self.request.user.avatar.delete()
return super().form_valid(form)
我想要更改链接,如下所示
<form action="" method="post" enctype="multipart/form-data">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="save" />
</form>
在图片上,我该怎么做?